Closed tgsmith61591 closed 5 years ago
The LP solver only deals with linear constraints.
See https://github.com/google/or-tools/blob/master/ortools/linear_solver/samples/linear_programming_example.py, and https://github.com/google/or-tools/blob/master/ortools/linear_solver/samples/integer_programming_example.py.
If you wish to look at CP examples, I recommend using the CP-SAT solver:
See https://github.com/google/or-tools/blob/master/ortools/sat/doc/index.md
Note that we are revamping https://developers.google.com/optimization/introduction/overview to add the CP-SAT solver for all CP examples. This is not yet finished.
Thanks
Laurent Perron | Operations Research | lperron@google.com | (33) 1 42 68 53 00
Le mar. 13 nov. 2018 à 16:27, Taylor G Smith notifications@github.com a écrit :
I've been looking through examples and documentation, and I cannot figure out how to create a cumulative constraint for an LP solver. If my solver is, for instance:
from ortools.linear_solver import pywraplp
solver = pywraplp.Solver('SolveRoutingProblem', pywraplp.Solver.CBC_MIXED_INTEGER_PROGRAMMING)
On inspecting the solver attributes, I see nothing related to cumulative constraints:
dir(solver) ['ABNORMAL', 'AT_LOWER_BOUND', 'AT_UPPER_BOUND', 'Add', 'BASIC', 'BOP_INTEGER_PROGRAMMING', 'BoolVar', 'CBC_MIXED_INTEGER_PROGRAMMING', 'CLP_LINEAR_PROGRAMMING', 'Clear', 'ComputeConstraintActivities', 'ComputeExactConditionNumber', 'Constraint', 'EnableOutput', 'ExportModelAsLpFormat', 'ExportModelAsMpsFormat', 'FEASIBLE', 'FIXED_VALUE', 'FREE', 'GLOP_LINEAR_PROGRAMMING', 'INFEASIBLE', 'Infinity', 'IntVar', 'InterruptSolve', 'Iterations', 'LoadModelFromProto', 'LookupConstraint', 'LookupVariable', 'Maximize', 'Minimize', 'NOT_SOLVED', 'NumConstraints', 'NumVar', 'NumVariables', 'OPTIMAL', 'Objective', 'RowConstraint', 'SetSolverSpecificParametersAsString', 'SetTimeLimit', 'Solve', 'Sum', 'SupportsProblemType', 'SuppressOutput', 'UNBOUNDED', 'VerifySolution', 'WallTime', 'class', 'del', 'delattr', 'dict', 'dir', 'doc', 'eq', 'format', 'ge', 'getattr', 'getattribute', 'gt', 'hash', 'init', 'init_subclass', 'le', 'lt', 'module', 'ne', 'new', 'reduce', 'reduce_ex', 'repr', 'setattr', 'sizeof', 'str', 'subclasshook', 'swig_destroy', 'swig_getmethods', '__swig_setmethods', 'weakref__', 'infinity', 'iterations', 'nodes', 'set_time_limit', 'this', 'wall_time']
However I found this example https://groups.google.com/forum/#!topic/or-tools-discuss/CMWBUzgRbgA on the mailing list that suggests it can be done for CP solvers:
def test_cumulative_api(): solver = pywrapcp.Solver('Problem')
Vars
S=[solver.FixedDurationIntervalVar(0, 10, 5,False, "S_%s"%a) for a in range(10)]
C = solver.IntVar(2, 5) D = [a % 3 + 2 for a in range(10)] solver.Add(solver.Cumulative(S, D, C, "cumul"))
Any workaround you know of? Thanks!
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/google/or-tools/issues/930, or mute the thread https://github.com/notifications/unsubscribe-auth/AKj17ZZn9AgPhq9XfBb_UpsGVWoVNqFfks5uuuTWgaJpZM4Yb44N .
I've been looking through examples and documentation, and I cannot figure out how to create a cumulative constraint for an LP solver. If my solver is, for instance:
On inspecting the solver attributes, I see nothing related to cumulative constraints:
However I found this example on the mailing list that suggests it can be done for CP solvers:
Any workaround you know of? Thanks!