add a ortools package for python modules; kept compatibility; updated all examples
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
import sys
|
||||
from linear_solver import pywraplp
|
||||
from ortools.linear_solver import pywraplp
|
||||
|
||||
def main(sol = 'GLPK'):
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
|
||||
"""
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
from collections import defaultdict
|
||||
|
||||
#
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
|
||||
"""
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
def main():
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
"""
|
||||
import string, sys
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
def main(n=12):
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
|
||||
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
#
|
||||
# Decomposition of alldifferent_except_0
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
"""
|
||||
import sys, string, re
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
def main(problem_str="SEND+MORE=MONEY", base=10):
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
def main(cost, rows, cols):
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
import sys
|
||||
from linear_solver import pywraplp
|
||||
from ortools.linear_solver import pywraplp
|
||||
|
||||
def main(sol = 'GLPK'):
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
from google.apputils import app
|
||||
import gflags
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
FLAGS = gflags.FLAGS
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
import sys
|
||||
from linear_solver import pywraplp
|
||||
from ortools.linear_solver import pywraplp
|
||||
|
||||
|
||||
def main(sol = 'GLPK'):
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
import sys
|
||||
import string
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
def main(m=40, n=4):
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
import sys
|
||||
import string
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
import sys
|
||||
import string
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
def main(num_sol=3):
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
|
||||
import sys
|
||||
import string
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
#
|
||||
# circuit(x)
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
import sys, string
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
def main(unused_argv):
|
||||
# Create the solver.
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
|
||||
from linear_solver import pywraplp
|
||||
from ortools.linear_solver import pywraplp
|
||||
|
||||
def main(unused_argv):
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
"""
|
||||
|
||||
import sys
|
||||
from linear_solver import pywraplp
|
||||
from ortools.linear_solver import pywraplp
|
||||
|
||||
|
||||
def main(sol = 'GLPK'):
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
"""
|
||||
import sys,string
|
||||
from collections import *
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
|
||||
"""
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
#
|
||||
# Global constraint regular
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
import sys
|
||||
import string
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
def main(n=6):
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
import sys
|
||||
import string
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
import sys, string
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
def main(sols=1):
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
"""
|
||||
|
||||
from google.apputils import app
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
def main(_):
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
def decreasing(solver, x):
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
import sys, string
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
# converts a number (s) <-> an array of numbers (t) in the specific base.
|
||||
def toNum(solver, t, s, base):
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
"""
|
||||
|
||||
import sys
|
||||
from linear_solver import pywraplp
|
||||
from ortools.linear_solver import pywraplp
|
||||
|
||||
|
||||
def main(sol = 'GLPK'):
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
import sys
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
def main(row_sums="", col_sums=""):
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
"""
|
||||
import string, sys
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
#
|
||||
# Decomposition of modulo constraint
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
def dudeney(n):
|
||||
solver = pywrapcp.Solver('Dudeney')
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
import sys
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
# Puzzle 1 from
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
import sys, string
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
#
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
def main(values, lt):
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
"""
|
||||
|
||||
import sys
|
||||
from linear_solver import pywraplp
|
||||
from ortools.linear_solver import pywraplp
|
||||
|
||||
def main(sol = 'GLPK'):
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ of the rule.
|
||||
|
||||
from google.apputils import app
|
||||
import gflags
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
FLAGS = gflags.FLAGS
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
import sys
|
||||
import string
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
"""
|
||||
|
||||
from google.apputils import app
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
def BuildPairs(rows, cols):
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
from google.apputils import app
|
||||
|
||||
from linear_solver import pywraplp
|
||||
from ortools.linear_solver import pywraplp
|
||||
|
||||
|
||||
def RunIntegerExampleNaturalLanguageAPI(optimization_problem_type):
|
||||
|
||||
@@ -27,7 +27,7 @@ jobs. This is called the makespan.
|
||||
|
||||
from google.apputils import app
|
||||
import gflags
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
FLAGS = gflags.FLAGS
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
|
||||
import sys
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
#
|
||||
# Ensure that the sum of the segments
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
|
||||
import sys
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
#
|
||||
# Ensure that the sum of the segments
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
|
||||
import sys
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
#
|
||||
# Ensure that the sum of the segments
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
from google.apputils import app
|
||||
import gflags
|
||||
from algorithms import pywrapknapsack_solver
|
||||
from ortools.algorithms import pywrapknapsack_solver
|
||||
|
||||
FLAGS = gflags.FLAGS
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
def knapsack(solver, values, weights, n):
|
||||
z = solver.IntVar(0, 10000)
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
import sys
|
||||
from linear_solver import pywraplp
|
||||
from ortools.linear_solver import pywraplp
|
||||
|
||||
def main(sol = 'GLPK'):
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
import sys
|
||||
import string
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
def main(k=8, num_sol=0):
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_cp_solver/
|
||||
"""
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
def main(unused_argv):
|
||||
# Create the solver.
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
"""
|
||||
|
||||
import sys
|
||||
from linear_solver import pywraplp
|
||||
from ortools.linear_solver import pywraplp
|
||||
|
||||
def main(sol = 'GLPK'):
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
"""
|
||||
|
||||
import sys
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
|
||||
from google.apputils import app
|
||||
from graph import pywrapgraph
|
||||
from ortools.graph import pywrapgraph
|
||||
|
||||
|
||||
def RunAssignmentOn4x4Matrix():
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
from google.apputils import app
|
||||
|
||||
from linear_solver import pywraplp
|
||||
from ortools.linear_solver import pywraplp
|
||||
|
||||
|
||||
def RunLinearExampleNaturalLanguageAPI(optimization_problem_type):
|
||||
|
||||
@@ -24,7 +24,7 @@ distribute().
|
||||
|
||||
from google.apputils import app
|
||||
import gflags
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
FLAGS = gflags.FLAGS
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
import string, sys
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
def main(n=4):
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
import string, sys
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
def main(n=3):
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
import sys
|
||||
from linear_solver import pywraplp
|
||||
from ortools.linear_solver import pywraplp
|
||||
|
||||
#
|
||||
# main(n, use_output_matrix)
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
"""
|
||||
|
||||
import sys
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
def main():
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
import sys
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
import sys
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
default_r = 8
|
||||
default_c = 8
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
"""
|
||||
|
||||
import sys
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
|
||||
import sys
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
#
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
|
||||
import sys
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
#
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
|
||||
import sys
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
#
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
|
||||
import sys
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
#
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
"""
|
||||
import sys
|
||||
import string
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
def main(m=3, n=6, minimize_val=0):
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
def main(n=8):
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
import sys, string
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
def main(n=8):
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
import sys, string
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
def main(n=8, num_sol=0, print_sol=1):
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
"""
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
from collections import defaultdict
|
||||
|
||||
#
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
"""
|
||||
|
||||
import sys
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
def minus(solver, x, y, z):
|
||||
solver.Add(z == abs(x - y))
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
"""
|
||||
|
||||
import sys
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
#
|
||||
# No overlapping of tasks s1 and s2
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
"""
|
||||
|
||||
import sys
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
|
||||
import string, sys
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
#
|
||||
# converts a number (s) <-> an array of integers (t) in the specific base.
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
import sys
|
||||
import string
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
def main(show_all_max=0):
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
|
||||
import sys
|
||||
import string
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
def main():
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -17,16 +17,16 @@
|
||||
Production planning problem in Google or-tools.
|
||||
|
||||
From the OPL model production.mod.
|
||||
|
||||
|
||||
This model was created by Hakan Kjellerstrand (hakank@bonetmail.com)
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
|
||||
import sys
|
||||
from linear_solver import pywraplp
|
||||
from ortools.linear_solver import pywraplp
|
||||
|
||||
def main(sol = 'GLPK'):
|
||||
|
||||
|
||||
# Create the solver.
|
||||
|
||||
# using GLPK
|
||||
@@ -65,7 +65,7 @@ def main(sol = 'GLPK'):
|
||||
inside = [solver.NumVar(0, 10000, 'inside[%i]' % p )
|
||||
for p in range(num_products)]
|
||||
outside = [solver.NumVar(0, 10000, 'outside[%i]' % p )
|
||||
for p in range(num_products)]
|
||||
for p in range(num_products)]
|
||||
|
||||
# to minimize
|
||||
z = solver.Sum([inside_cost[p] * inside[p] + outside_cost[p] * outside[p]
|
||||
@@ -93,7 +93,7 @@ def main(sol = 'GLPK'):
|
||||
print 'outside:', outside[p].SolutionValue(), ' (ReducedCost:', outside[p].ReducedCost(), ')'
|
||||
print
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
sol = 'GLPK'
|
||||
@@ -102,5 +102,5 @@ if __name__ == '__main__':
|
||||
if sol != 'GLPK' and sol != 'CBC':
|
||||
print 'Solver must be either GLPK or CBC'
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
main(sol)
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
|
||||
from google.apputils import app
|
||||
from graph import pywrapgraph
|
||||
from ortools.graph import pywrapgraph
|
||||
|
||||
|
||||
def MaxFlow():
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
"""
|
||||
|
||||
import sys
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
default_n = 5
|
||||
X = 0
|
||||
|
||||
@@ -23,7 +23,7 @@ flavors of constraint programming interfaces.
|
||||
|
||||
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
"""
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
#
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
"""
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
#
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
"""
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
#
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
"""
|
||||
import sys, string, re
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
def main(problem, rows, cols, max_steps):
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
Also see my other Google CP Solver models: http://www.hakank.org/google_or_tools/
|
||||
"""
|
||||
import sys
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
"""
|
||||
|
||||
import sys
|
||||
from constraint_solver import pywrapcp
|
||||
from ortools.constraint_solver import pywrapcp
|
||||
|
||||
|
||||
def main(singe=0):
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user