This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""https://www.coursera.org/learn/ml-foundations?specialization=machine-learning#about""" | |
from matplotlib import pyplot | |
import pandas | |
import seaborn | |
from sklearn import linear_model | |
from sklearn import model_selection | |
from sklearn import metrics | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ortools.linear_solver import pywraplp | |
''' | |
Pricing out: | |
- This idea is used in Column Generation | |
- Course: https://www.edx.org/course/optimization-methods-for-business-analytics, Week5 | |
============================================================================== | |
Idea |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math, random, networkx | |
from matplotlib import pyplot | |
def getData(): | |
data = {} | |
data["locationList"] = ["Depot", "loc1", "loc2", "loc3", "loc4", "loc5", "loc6", "loc7", "loc8", "loc9", "loc10"] | |
data["travelMatrix"] = {'Depot': {'Depot': 0, 'loc1': 35, 'loc2': 10, 'loc3': 15, 'loc4': 23, 'loc5': 20, 'loc6': 34, 'loc7': 3, 'loc8': 37, 'loc9': 12, "loc10": 20}, | |
'loc1': {'Depot': 35, 'loc1': 0, 'loc2': 25, 'loc3': 22, 'loc4': 12, 'loc5': 18, 'loc6': 14, 'loc7': 37, 'loc8': 6, 'loc9': 23, "loc10": 20}, | |
'loc2': {'Depot': 10, 'loc1': 25, 'loc2': 0, 'loc3': 5, 'loc4': 13, 'loc5': 11, 'loc6': 25, 'loc7': 12, 'loc8': 27, 'loc9': 4, "loc10": 13}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ortools.sat.python import cp_model | |
import random | |
''' course: https://www.coursera.org/learn/solving-algorithms-discrete-optimization#about | |
About solver strategies and how global constraints work''' | |
def theYaoCaoModel(): | |
model = cp_model.CpModel() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ortools.sat.python import cp_model | |
''' course: https://www.coursera.org/learn/solving-algorithms-discrete-optimization#about | |
About how cp works and intro to solver strategies''' | |
def patchingThe9HeavensProblem(): #sudoku problem | |
model = cp_model.CpModel() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ortools.sat.python import cp_model | |
''' course: https://www.coursera.org/learn/advanced-modeling#about | |
These models have different classes of symmetries. | |
Week6 is about symmetries. | |
Currently ortools don't have methods for symmetry breaking ''' | |
def crossbowTrapProblem(): # nqueens problem |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ortools.sat.python import cp_model | |
''' course: https://www.coursera.org/learn/advanced-modeling#about ''' | |
def squarePackingProblem(): | |
model = cp_model.CpModel() | |
copyList = [4, 3, 0, 5, 4, 3, 4] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ortools.sat.python import cp_model | |
''' course: https://www.coursera.org/learn/advanced-modeling#about ''' | |
def basicScheduling(): | |
model = cp_model.CpModel() | |
taskList = ["FUNDS", "SOLDIERS", "DEFENSE", "WEAPONRY", "ELITEARMY", "RAW_MATERIALS", "CRAFTSMEN", "CASTING", "BRICKS", "WALL"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ortools.sat.python import cp_model | |
''' course: https://www.coursera.org/learn/advanced-modeling#about ''' | |
def formTeam(model, booleanVarList, archerList, cavalryList, infantryList): | |
varList = [] | |
for archer in archerList: | |
varList.append(booleanVarList[archer]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ortools.sat.python import cp_model | |
''' course: https://www.coursera.org/learn/advanced-modeling#about ''' | |
def theCavalryWedgeProblem(): | |
model = cp_model.CpModel() | |
horseList = ["H1", "H2", "H3", "H4", "H5", "H6", "H7", "H8", "H9", "H10"] | |
riderList = ["R1", "R2", "R3", "R4", "R5", "R6", "R7", "R8", "R9", "R10", "R11"] |