Created
October 9, 2020 07:08
-
-
Save braindeaf/66b391e0f7a7d896a45925c167168498 to your computer and use it in GitHub Desktop.
My First Solver - are you proud of me?
This file contains 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
#!/usr/local/bin/python3 | |
from __future__ import print_function | |
from ortools.linear_solver import pywraplp | |
t = 'WhatIsX' | |
s = pywraplp.Solver(t, pywraplp.Solver.GLOP_LINEAR_PROGRAMMING) | |
x = s.NumVar(0, 1000, 'x') | |
s.Add(x + 2*x + 3*x + 4*x == 10) # it's almost algebraic syntax | |
s.Solve() | |
print(x.SolutionValue()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment