Skip to content

Instantly share code, notes, and snippets.

View syedmisbah's full-sized avatar
:octocat:
Working or sleeping!

Syed Misbah syedmisbah

:octocat:
Working or sleeping!
View GitHub Profile
@syedmisbah
syedmisbah / 1. Intro to Optimization.py
Last active December 25, 2019 07:26
Embed code for Intro to Optimization
#Import ortools solver
from ortools.linear_solver import pywraplp
#Creating a solver object
solver_lin = pywraplp.Solver('Swiggy Food Solver',pywraplp.Solver.GLOP_LINEAR_PROGRAMMING)
#Step 1 - Create Decision variables
# x[0] for number of biryanis
# x[1] for number of Bowls
#Function for solver
def solve_gas(InputRawMaterial, D):
s = newSolver('Gas blending problem')
nR,nF = len(InputRawMaterial),len(D)
Roc,Rmax,Rcost = 0,1,2
Foc,Fmin,Fmax,Fprice = 0,1,2,3
G = [[s.NumVar(0.0,10000,'')
for j in range(nF)] for i in range(nR)]
ProductList = [s.NumVar(0,InputRawMaterial[i][Rmax],'') for i in range(nR)]
F = [s.NumVar(D[j][Fmin],D[j][Fmax],'') for j in range(nF)]
#SetWD
setwd("C:/Users/misba/Desktop/PROCESS/")
#Load libraires
library(dplyr)
library(raster)
library(rgdal)
library(data.table)
#Read object
#Import libraries
import pyproj
import pandas as pd
#Pyspark functions - ONLY - DO not import functions like "import * from <package name>"
from pyspark.sql.functions import *
from pyspark.sql.types import DoubleType
#Read dataframe with XY(eastings and northings) and population value