2014-07-09 11:17:29 +00:00
|
|
|
// Copyright 2010-2014 Google
|
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
|
//
|
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
//
|
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
|
// limitations under the License.
|
2014-07-09 15:18:27 +00:00
|
|
|
|
2014-07-09 11:17:29 +00:00
|
|
|
// This .swig file exposes the code declared in ../constraint_solver.h and
|
|
|
|
|
// ../constraint_solveri.h.
|
|
|
|
|
//
|
|
|
|
|
// It is particularly complex for a swig file, mostly because it contains a
|
|
|
|
|
// lot of MOE code for the export to the or-tools open-source project at
|
|
|
|
|
// powerful python API thanks to the possible use of directors.
|
|
|
|
|
//
|
|
|
|
|
// USAGE EXAMPLES (most of which are also unit tests):
|
|
|
|
|
// - ./pywrapcp_test.py
|
|
|
|
|
// - python/appointments.py
|
|
|
|
|
// - python/golomb8.py
|
|
|
|
|
// - python/hidato_table.py
|
|
|
|
|
// - python/jobshop_ft06.py
|
|
|
|
|
// - python/magic_sequence_distribute.py
|
|
|
|
|
// - python/rabbit_pheasant.py
|
|
|
|
|
// - python/simple_meeting.py
|
|
|
|
|
// - python/sudoku.py
|
|
|
|
|
// - python/zebra.py
|
|
|
|
|
|
|
|
|
|
%include "base/base.swig"
|
|
|
|
|
|
2015-11-02 15:27:08 +01:00
|
|
|
// PY_CONVERT_HELPER_* macros.
|
|
|
|
|
%include "constraint_solver/python/constraint_solver_helpers.swig"
|
2014-07-09 11:17:29 +00:00
|
|
|
|
|
|
|
|
// Callback wrapping. See base/python/callbacks.swig.
|
|
|
|
|
#define FATAL_CALLBACK_EXCEPTION
|
|
|
|
|
%include "base/python/callbacks.swig"
|
|
|
|
|
|
2015-11-02 15:27:08 +01:00
|
|
|
// std::function utilities.
|
|
|
|
|
%include "util/python/functions.swig"
|
|
|
|
|
|
|
|
|
|
%import "util/python/data.swig"
|
|
|
|
|
|
2014-07-09 11:17:29 +00:00
|
|
|
// We *do* need to use SWIGTYPE_... type names directly, because the
|
|
|
|
|
// (recommended replacement) $descriptor macro fails, as of 2014-06, with
|
|
|
|
|
// types such as operations_research::Solver.
|
|
|
|
|
// The absence of whitespace before 'swiglint' is mandatory.
|
|
|
|
|
//swiglint: disable swigtype-name
|
2014-06-13 10:03:03 +00:00
|
|
|
|
|
|
|
|
%{
|
2015-11-20 18:43:11 +01:00
|
|
|
#include <setjmp.h> // For FailureProtect. See below.
|
2015-11-20 11:40:39 +01:00
|
|
|
|
2015-11-20 18:43:11 +01:00
|
|
|
// Used in the PROTECT_FROM_FAILURE macro. See below.
|
2015-11-20 11:40:39 +01:00
|
|
|
struct FailureProtect {
|
|
|
|
|
jmp_buf exception_buffer;
|
|
|
|
|
void JumpBack() { longjmp(exception_buffer, 1); }
|
|
|
|
|
};
|
2015-11-20 18:43:11 +01:00
|
|
|
|
|
|
|
|
// This #includes constraint_solver.h, and inlines some C++ helpers.
|
|
|
|
|
#include "constraint_solver/python/pywrapcp_util.h"
|
2014-06-13 10:03:03 +00:00
|
|
|
%}
|
|
|
|
|
|
2014-07-09 11:17:29 +00:00
|
|
|
// We need to fully support C++ inheritance, because it is heavily used by the
|
|
|
|
|
// exposed C++ classes. Eg:
|
|
|
|
|
// class BaseClass {
|
|
|
|
|
// virtual void Foo() { ... }
|
|
|
|
|
// virtual void Bar() { Foo(); ... }
|
|
|
|
|
// };
|
|
|
|
|
// ...
|
|
|
|
|
// class SubClass {
|
|
|
|
|
// // Overrides Foo; and expects the inherited Bar() to use
|
|
|
|
|
// // the overriden Foo().
|
|
|
|
|
// virtual void Foo() { ... }
|
|
|
|
|
// };
|
|
|
|
|
//
|
|
|
|
|
// See the occurrences of "director" in this file.
|
2014-05-22 12:02:12 +00:00
|
|
|
%module(directors="1") operations_research
|
2014-07-24 18:49:13 +00:00
|
|
|
#pragma SWIG nowarn=473
|
|
|
|
|
|
2014-07-09 11:17:29 +00:00
|
|
|
// The %feature and %exception below let python exceptions that occur within
|
|
|
|
|
// director method propagate to the user as they were originally. See
|
|
|
|
|
// http://www.swig.org/Doc1.3/Python.html#Python_nn36 for example.
|
|
|
|
|
%feature("director:except") {
|
|
|
|
|
if ($error != NULL) {
|
|
|
|
|
throw Swig::DirectorMethodException();
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
2011-07-26 18:31:56 +00:00
|
|
|
}
|
2014-07-09 11:17:29 +00:00
|
|
|
%exception {
|
|
|
|
|
try { $action }
|
|
|
|
|
catch (Swig::DirectorException &e) { SWIG_fail; }
|
|
|
|
|
}
|
2011-07-26 18:31:56 +00:00
|
|
|
|
2012-03-19 17:14:57 +00:00
|
|
|
|
2014-07-09 11:17:29 +00:00
|
|
|
// ============= Type conversions ==============
|
|
|
|
|
|
2015-11-02 15:27:08 +01:00
|
|
|
// See ./constraint_solver_helpers.swig
|
2015-12-07 13:27:18 +01:00
|
|
|
PY_CONVERT_HELPER_PTR(Decision);
|
2015-12-07 13:05:16 +01:00
|
|
|
PY_CONVERT_HELPER_PTR(DecisionBuilder);
|
2013-12-10 16:02:46 +00:00
|
|
|
PY_CONVERT_HELPER_PTR(SearchMonitor);
|
|
|
|
|
PY_CONVERT_HELPER_PTR(IntervalVar);
|
|
|
|
|
PY_CONVERT_HELPER_PTR(SequenceVar);
|
|
|
|
|
PY_CONVERT_HELPER_PTR(LocalSearchOperator);
|
|
|
|
|
PY_CONVERT_HELPER_PTR(LocalSearchFilter);
|
|
|
|
|
PY_CONVERT_HELPER_INTEXPR_OR_INTVAR(IntVar);
|
|
|
|
|
PY_CONVERT_HELPER_INTEXPR_OR_INTVAR(IntExpr);
|
2010-09-15 12:42:33 +00:00
|
|
|
|
|
|
|
|
|
2014-07-09 11:17:29 +00:00
|
|
|
// Actual conversions. This also includes the conversion to std::vector<Class>.
|
2013-12-10 16:02:46 +00:00
|
|
|
%define PY_CONVERT(Class)
|
|
|
|
|
%{
|
|
|
|
|
bool CanConvertTo ## Class(PyObject *py_obj) {
|
|
|
|
|
operations_research::Class* tmp;
|
|
|
|
|
return PyObjAs(py_obj, &tmp);
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
2013-12-10 16:02:46 +00:00
|
|
|
%}
|
2014-07-09 11:17:29 +00:00
|
|
|
%typemap(in) operations_research::Class* const {
|
|
|
|
|
if (!PyObjAs($input, &$1)) SWIG_fail;
|
|
|
|
|
}
|
|
|
|
|
%typecheck(SWIG_TYPECHECK_POINTER) operations_research::Class* const {
|
2013-12-10 16:02:46 +00:00
|
|
|
$1 = CanConvertTo ## Class($input);
|
|
|
|
|
if ($1 == 0) PyErr_Clear();
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
2013-12-10 16:02:46 +00:00
|
|
|
PY_LIST_OUTPUT_TYPEMAP(operations_research::Class*, CanConvertTo ## Class,
|
|
|
|
|
PyObjAs<operations_research::Class*>);
|
2012-02-09 19:42:18 +00:00
|
|
|
%enddef
|
2013-12-10 16:02:46 +00:00
|
|
|
PY_CONVERT(IntVar);
|
|
|
|
|
PY_CONVERT(IntExpr);
|
2015-12-07 13:27:18 +01:00
|
|
|
PY_CONVERT(Decision);
|
2013-12-10 16:02:46 +00:00
|
|
|
PY_CONVERT(DecisionBuilder);
|
|
|
|
|
PY_CONVERT(SearchMonitor);
|
|
|
|
|
PY_CONVERT(IntervalVar);
|
|
|
|
|
PY_CONVERT(SequenceVar);
|
|
|
|
|
PY_CONVERT(LocalSearchOperator);
|
|
|
|
|
PY_CONVERT(LocalSearchFilter);
|
|
|
|
|
#undef PY_CONVERT
|
2010-09-15 12:42:33 +00:00
|
|
|
|
2015-11-20 11:32:37 +01:00
|
|
|
// Support passing std::function<void(Solver*)> as argument.
|
|
|
|
|
|
|
|
|
|
%{
|
|
|
|
|
static void PyFunctionSolverToVoid(PyObject* pyfunc,
|
|
|
|
|
operations_research::Solver* s) {
|
|
|
|
|
// () needed to force creation of one-element tuple
|
|
|
|
|
PyObject* const pysolver =
|
|
|
|
|
SWIG_NewPointerObj(s, SWIGTYPE_p_operations_research__Solver,
|
|
|
|
|
SWIG_POINTER_EXCEPTION);
|
|
|
|
|
PyObject* const pyresult = PyEval_CallFunction(pyfunc, "(O)", pysolver);
|
|
|
|
|
if (!pyresult) {
|
|
|
|
|
PyErr_SetString(PyExc_RuntimeError,
|
|
|
|
|
"std::function<void(Solver*)> invocation failed.");
|
|
|
|
|
} else {
|
|
|
|
|
Py_DECREF(pyresult);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
%}
|
|
|
|
|
|
|
|
|
|
%typecheck(SWIG_TYPECHECK_POINTER) std::function<void(
|
|
|
|
|
operations_research::Solver*)> {
|
|
|
|
|
$1 = PyCallable_Check($input);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
%typemap(in) std::function<void(operations_research::Solver*)> {
|
|
|
|
|
$1 = [$input](operations_research::Solver* s) {
|
|
|
|
|
return PyFunctionSolverToVoid($input, s);
|
|
|
|
|
};
|
|
|
|
|
}
|
2010-09-15 12:42:33 +00:00
|
|
|
|
2014-07-09 11:17:29 +00:00
|
|
|
// ============= Extensions ==============
|
|
|
|
|
|
|
|
|
|
// Add display methods on BaseObject and Solver.
|
|
|
|
|
%extend operations_research::Solver {
|
2014-07-24 18:12:50 +00:00
|
|
|
std::string __str__() {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->DebugString();
|
2012-01-28 09:28:19 +00:00
|
|
|
}
|
2016-01-05 22:35:02 +01:00
|
|
|
%pythoncode {
|
|
|
|
|
def Add(self, ct):
|
|
|
|
|
if isinstance(ct, PyConstraint):
|
|
|
|
|
self.__python_constraints.append(ct)
|
|
|
|
|
self.AddConstraint(ct)
|
|
|
|
|
} // %pythoncode
|
2011-01-21 13:42:29 +00:00
|
|
|
}
|
2010-09-15 12:42:33 +00:00
|
|
|
|
2016-01-05 22:35:02 +01:00
|
|
|
%feature("pythonappend") operations_research::Solver::Solver %{
|
|
|
|
|
self.__python_constraints = []
|
|
|
|
|
%}
|
|
|
|
|
|
2014-07-09 11:17:29 +00:00
|
|
|
// Extend IntervalVar to provide a nicer pythonic API for precedence
|
|
|
|
|
// and scheduling constraints. The macros below help do that concisely.
|
|
|
|
|
%define PRECEDENCE_CONSTRAINT(PythonMethodName, CppEnumName)
|
|
|
|
|
Constraint* PythonMethodName(IntervalVar* other) {
|
|
|
|
|
return $self->solver()->MakeIntervalVarRelation(
|
|
|
|
|
$self, operations_research::Solver::CppEnumName, other);
|
|
|
|
|
}
|
2015-08-13 16:00:54 +02:00
|
|
|
|
|
|
|
|
Constraint* PythonMethodName##WithDelay(IntervalVar* other, int64 delay) {
|
|
|
|
|
return $self->solver()->MakeIntervalVarRelationWithDelay(
|
|
|
|
|
$self, operations_research::Solver::CppEnumName, other, delay);
|
|
|
|
|
}
|
2014-07-09 11:17:29 +00:00
|
|
|
%enddef
|
|
|
|
|
%define SCHEDULING_CONSTRAINT(PythonMethodName, CppEnumName)
|
|
|
|
|
Constraint* PythonMethodName(int64 date) {
|
|
|
|
|
return $self->solver()->MakeIntervalVarRelation(
|
|
|
|
|
$self, operations_research::Solver::CppEnumName, date);
|
|
|
|
|
}
|
|
|
|
|
%enddef
|
|
|
|
|
%extend operations_research::IntervalVar {
|
|
|
|
|
PRECEDENCE_CONSTRAINT(EndsAfterEnd, ENDS_AFTER_END)
|
|
|
|
|
PRECEDENCE_CONSTRAINT(EndsAfterStart, ENDS_AFTER_START)
|
|
|
|
|
PRECEDENCE_CONSTRAINT(EndsAtEnd, ENDS_AT_END)
|
|
|
|
|
PRECEDENCE_CONSTRAINT(EndsAtStart, ENDS_AT_START)
|
|
|
|
|
PRECEDENCE_CONSTRAINT(StartsAfterEnd, STARTS_AFTER_END)
|
|
|
|
|
PRECEDENCE_CONSTRAINT(StartsAfterStart, STARTS_AFTER_START)
|
|
|
|
|
PRECEDENCE_CONSTRAINT(StartsAtEnd, STARTS_AT_END)
|
|
|
|
|
PRECEDENCE_CONSTRAINT(StartsAtStart, STARTS_AT_START)
|
|
|
|
|
PRECEDENCE_CONSTRAINT(StaysInSync, STAYS_IN_SYNC)
|
|
|
|
|
SCHEDULING_CONSTRAINT(EndsAfter, ENDS_AFTER)
|
|
|
|
|
SCHEDULING_CONSTRAINT(EndsAt, ENDS_AT)
|
|
|
|
|
SCHEDULING_CONSTRAINT(EndsBefore, ENDS_BEFORE)
|
|
|
|
|
SCHEDULING_CONSTRAINT(StartsAfter, STARTS_AFTER)
|
|
|
|
|
SCHEDULING_CONSTRAINT(StartsAt, STARTS_AT)
|
|
|
|
|
SCHEDULING_CONSTRAINT(StartsBefore, STARTS_BEFORE)
|
|
|
|
|
SCHEDULING_CONSTRAINT(CrossesDate, CROSS_DATE)
|
|
|
|
|
SCHEDULING_CONSTRAINT(AvoidsDate, AVOID_DATE)
|
|
|
|
|
}
|
|
|
|
|
#undef PRECEDENCE_CONSTRAINT
|
|
|
|
|
#undef SCHEDULING_CONSTRAINT
|
|
|
|
|
|
2014-07-24 18:27:32 +00:00
|
|
|
// Use DebugString() for the native std::string conversion in python, for objects
|
2014-07-09 11:17:29 +00:00
|
|
|
// that support it.
|
2013-12-10 16:02:46 +00:00
|
|
|
%define PY_STRINGIFY_DEBUGSTRING(Class)
|
2014-07-09 11:17:29 +00:00
|
|
|
%extend operations_research::Class {
|
2014-07-24 18:12:50 +00:00
|
|
|
std::string __repr__() {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->DebugString();
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
2015-12-07 13:05:16 +01:00
|
|
|
|
|
|
|
|
std::string __str__() {
|
|
|
|
|
return $self->DebugString();
|
|
|
|
|
}
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
2013-12-10 16:02:46 +00:00
|
|
|
%enddef
|
2014-07-09 11:17:29 +00:00
|
|
|
PY_STRINGIFY_DEBUGSTRING(BaseObject);
|
|
|
|
|
PY_STRINGIFY_DEBUGSTRING(IntervalVar);
|
2013-12-10 16:02:46 +00:00
|
|
|
PY_STRINGIFY_DEBUGSTRING(SequenceVar);
|
|
|
|
|
PY_STRINGIFY_DEBUGSTRING(IntVar);
|
|
|
|
|
PY_STRINGIFY_DEBUGSTRING(IntExpr);
|
|
|
|
|
PY_STRINGIFY_DEBUGSTRING(Constraint);
|
|
|
|
|
PY_STRINGIFY_DEBUGSTRING(SearchMonitor);
|
|
|
|
|
PY_STRINGIFY_DEBUGSTRING(DecisionBuilder);
|
|
|
|
|
PY_STRINGIFY_DEBUGSTRING(Decision);
|
|
|
|
|
#undef PY_STRINGIFY_DEBUGSTRING
|
2010-09-15 12:42:33 +00:00
|
|
|
|
2014-07-09 11:17:29 +00:00
|
|
|
// Extend the solver with a few nicer pythonic methods.
|
|
|
|
|
%extend operations_research::Solver {
|
2011-05-17 20:38:55 +00:00
|
|
|
Constraint* TreeNoCycle(const std::vector<IntVar*>& nexts,
|
|
|
|
|
const std::vector<IntVar*>& active,
|
2015-08-13 16:00:54 +02:00
|
|
|
Solver::IndexFilter1 callback = nullptr) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->MakeNoCycle(nexts, active, callback, false);
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
2011-01-21 13:42:29 +00:00
|
|
|
|
2010-09-15 12:42:33 +00:00
|
|
|
SearchMonitor* SearchLogWithCallback(int period,
|
2015-08-13 16:00:54 +02:00
|
|
|
std::function<std::string()> callback) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->MakeSearchLog(period, callback);
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
|
|
|
|
|
2015-08-13 16:00:54 +02:00
|
|
|
IntExpr* ElementFunction(std::function<int64(int64)> values,
|
2010-09-15 12:42:33 +00:00
|
|
|
IntVar* const index) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->MakeElement(values, index);
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DecisionBuilder* VarEvalValStrPhase(
|
2011-05-17 20:38:55 +00:00
|
|
|
const std::vector<IntVar*>& vars,
|
2015-08-13 16:00:54 +02:00
|
|
|
std::function<int64(int64)> var_evaluator,
|
2010-09-15 12:42:33 +00:00
|
|
|
operations_research::Solver::IntValueStrategy val_str) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->MakePhase(vars, var_evaluator, val_str);
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DecisionBuilder* VarStrValEvalPhase(
|
2011-05-17 20:38:55 +00:00
|
|
|
const std::vector<IntVar*>& vars,
|
2010-09-15 12:42:33 +00:00
|
|
|
operations_research::Solver::IntVarStrategy var_str,
|
2015-08-13 16:00:54 +02:00
|
|
|
Solver::IndexEvaluator2 val_eval) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->MakePhase(vars, var_str, val_eval);
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DecisionBuilder* VarEvalValEvalPhase(
|
2011-05-17 20:38:55 +00:00
|
|
|
const std::vector<IntVar*>& vars,
|
2015-08-13 16:00:54 +02:00
|
|
|
std::function<int64(int64)> var_eval,
|
|
|
|
|
Solver::IndexEvaluator2 val_eval) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->MakePhase(vars, var_eval, val_eval);
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DecisionBuilder* VarStrValEvalTieBreakPhase(
|
2011-05-17 20:38:55 +00:00
|
|
|
const std::vector<IntVar*>& vars,
|
2010-09-15 12:42:33 +00:00
|
|
|
operations_research::Solver::IntVarStrategy var_str,
|
2015-08-13 16:00:54 +02:00
|
|
|
Solver::IndexEvaluator2 val_eval,
|
|
|
|
|
std::function<int64(int64)> tie_breaker) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->MakePhase(vars, var_str, val_eval, tie_breaker);
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DecisionBuilder* VarEvalValEvalTieBreakPhase(
|
2011-05-17 20:38:55 +00:00
|
|
|
const std::vector<IntVar*>& vars,
|
2015-08-13 16:00:54 +02:00
|
|
|
std::function<int64(int64)> var_eval,
|
|
|
|
|
Solver::IndexEvaluator2 val_eval,
|
|
|
|
|
std::function<int64(int64)> tie_breaker) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->MakePhase(vars, var_eval, val_eval, tie_breaker);
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DecisionBuilder* EvalEvalStrPhase(
|
2011-05-17 20:38:55 +00:00
|
|
|
const std::vector<IntVar*>& vars,
|
2015-08-13 16:00:54 +02:00
|
|
|
Solver::IndexEvaluator2 evaluator,
|
2010-09-15 12:42:33 +00:00
|
|
|
operations_research::Solver::EvaluatorStrategy str) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->MakePhase(vars, evaluator, str);
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DecisionBuilder* EvalEvalStrTieBreakPhase(
|
2011-05-17 20:38:55 +00:00
|
|
|
const std::vector<IntVar*>& vars,
|
2015-08-13 16:00:54 +02:00
|
|
|
Solver::IndexEvaluator2 evaluator,
|
|
|
|
|
Solver::IndexEvaluator1 tie_breaker,
|
2010-09-15 12:42:33 +00:00
|
|
|
operations_research::Solver::EvaluatorStrategy str) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->MakePhase(vars, evaluator, tie_breaker, str);
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SearchMonitor* GuidedLocalSearch(
|
|
|
|
|
bool maximize,
|
|
|
|
|
IntVar* const objective,
|
2015-08-13 16:00:54 +02:00
|
|
|
Solver::IndexEvaluator2 objective_function,
|
2010-09-15 12:42:33 +00:00
|
|
|
int64 step,
|
2011-05-17 20:38:55 +00:00
|
|
|
const std::vector<IntVar*>& vars,
|
2010-09-15 12:42:33 +00:00
|
|
|
double penalty_factor) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->MakeGuidedLocalSearch(maximize,
|
2010-09-15 12:42:33 +00:00
|
|
|
objective,
|
|
|
|
|
objective_function,
|
|
|
|
|
step,
|
|
|
|
|
vars,
|
|
|
|
|
penalty_factor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LocalSearchFilter* LocalSearchObjectiveFilter(
|
2011-05-17 20:38:55 +00:00
|
|
|
const std::vector<IntVar*>& vars,
|
2015-08-13 16:00:54 +02:00
|
|
|
Solver::IndexEvaluator2 values,
|
2013-10-10 15:23:20 +00:00
|
|
|
IntVar* const objective,
|
2010-09-15 12:42:33 +00:00
|
|
|
Solver::LocalSearchFilterBound filter_enum,
|
|
|
|
|
Solver::LocalSearchOperation op_enum) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->MakeLocalSearchObjectiveFilter(vars,
|
2010-09-15 12:42:33 +00:00
|
|
|
values,
|
|
|
|
|
objective,
|
|
|
|
|
filter_enum,
|
|
|
|
|
op_enum);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Add arithmetic operators to integer expressions.
|
2014-07-09 11:17:29 +00:00
|
|
|
%extend operations_research::IntExpr {
|
2010-09-15 12:42:33 +00:00
|
|
|
IntExpr* __add__(IntExpr* other) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeSum($self, other);
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
2012-03-19 17:14:57 +00:00
|
|
|
IntExpr* __add__(Constraint* other) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeSum($self, other->Var());
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
2010-09-15 12:42:33 +00:00
|
|
|
IntExpr* __add__(int64 v) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeSum($self, v);
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
|
|
|
|
IntExpr* __radd__(int64 v) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeSum($self, v);
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
|
|
|
|
IntExpr* __sub__(IntExpr* other) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeDifference($self, other);
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
2012-03-19 17:14:57 +00:00
|
|
|
IntExpr* __sub__(Constraint* other) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeDifference($self, other->Var());
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
2010-09-15 12:42:33 +00:00
|
|
|
IntExpr* __sub__(int64 v) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeSum($self, -v);
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
|
|
|
|
IntExpr* __rsub__(int64 v) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeDifference(v, $self);
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
|
|
|
|
IntExpr* __mul__(IntExpr* other) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeProd($self, other);
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
2012-03-19 17:14:57 +00:00
|
|
|
IntExpr* __mul__(Constraint* other) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeProd($self, other->Var());
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
2010-09-15 12:42:33 +00:00
|
|
|
IntExpr* __mul__(int64 v) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeProd($self, v);
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
|
|
|
|
IntExpr* __rmul__(int64 v) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeProd($self, v);
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
|
|
|
|
IntExpr* __floordiv__(int64 v) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeDiv($self, v);
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
2013-04-14 20:21:30 +00:00
|
|
|
IntExpr* __mod__(int64 v) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeModulo($self, v);
|
2013-04-14 20:21:30 +00:00
|
|
|
}
|
|
|
|
|
IntExpr* __mod__(IntExpr* e) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeModulo($self, e);
|
2013-04-14 20:21:30 +00:00
|
|
|
}
|
2010-09-15 12:42:33 +00:00
|
|
|
IntExpr* __neg__() {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeOpposite($self);
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
|
|
|
|
IntExpr* __abs__() {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeAbs($self);
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
|
|
|
|
IntExpr* Square() {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeSquare($self);
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Constraint* __eq__(int64 v) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeEquality($self, v);
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
|
|
|
|
Constraint* __ne__(int64 v) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeNonEquality($self->Var(), v);
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
|
|
|
|
Constraint* __ge__(int64 v) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeGreaterOrEqual($self, v);
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
|
|
|
|
Constraint* __gt__(int64 v) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeGreater($self, v);
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
|
|
|
|
Constraint* __le__(int64 v) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeLessOrEqual($self, v);
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
|
|
|
|
Constraint* __lt__(int64 v) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeLess($self, v);
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
|
|
|
|
Constraint* __eq__(IntExpr* other) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeEquality($self->Var(), other->Var());
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
|
|
|
|
Constraint* __ne__(IntExpr* other) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeNonEquality($self->Var(), other->Var());
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
|
|
|
|
Constraint* __ge__(IntExpr* other) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeGreaterOrEqual($self->Var(), other->Var());
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
|
|
|
|
Constraint* __gt__(IntExpr* other) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeGreater($self->Var(), other->Var());
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
|
|
|
|
Constraint* __le__(IntExpr* other) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeLessOrEqual($self->Var(), other->Var());
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
|
|
|
|
Constraint* __lt__(IntExpr* other) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeLess($self->Var(), other->Var());
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
2012-03-19 17:14:57 +00:00
|
|
|
Constraint* __eq__(Constraint* other) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeEquality($self->Var(), other->Var());
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
Constraint* __ne__(Constraint* other) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeNonEquality($self->Var(), other->Var());
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
Constraint* __ge__(Constraint* other) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeGreaterOrEqual($self->Var(), other->Var());
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
Constraint* __gt__(Constraint* other) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeGreater($self->Var(), other->Var());
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
Constraint* __le__(Constraint* other) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeLessOrEqual($self->Var(), other->Var());
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
Constraint* __lt__(Constraint* other) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeLess($self->Var(), other->Var());
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
2011-05-17 20:38:55 +00:00
|
|
|
Constraint* MapTo(const std::vector<IntVar*>& vars) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeMapDomain($self->Var(), vars);
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
2014-07-22 17:46:28 +00:00
|
|
|
IntExpr* IndexOf(const std::vector<int64>& vars) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeElement(vars, $self->Var());
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
2014-07-22 17:46:28 +00:00
|
|
|
IntExpr* IndexOf(const std::vector<IntVar*>& vars) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeElement(vars, $self->Var());
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
2013-03-10 20:13:49 +00:00
|
|
|
IntVar* IsMember(const std::vector<int64>& values) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeIsMemberVar($self->Var(), values);
|
2013-03-10 20:13:49 +00:00
|
|
|
}
|
|
|
|
|
Constraint* Member(const std::vector<int64>& values) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeMemberCt($self->Var(), values);
|
2013-03-10 20:13:49 +00:00
|
|
|
}
|
2010-09-15 12:42:33 +00:00
|
|
|
}
|
|
|
|
|
|
2012-03-19 17:14:57 +00:00
|
|
|
// Add arithmetic operators to integer expressions.
|
2014-07-09 11:17:29 +00:00
|
|
|
%extend operations_research::Constraint {
|
2012-03-19 17:14:57 +00:00
|
|
|
IntExpr* __add__(IntExpr* other) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeSum($self->Var(), other);
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
IntExpr* __add__(Constraint* other) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeSum($self->Var(), other->Var());
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
IntExpr* __add__(int64 v) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeSum($self->Var(), v);
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
IntExpr* __radd__(int64 v) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeSum($self->Var(), v);
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
IntExpr* __sub__(IntExpr* other) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeDifference($self->Var(), other);
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
IntExpr* __sub__(Constraint* other) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeDifference($self->Var(), other->Var());
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
IntExpr* __sub__(int64 v) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeSum($self->Var(), -v);
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
IntExpr* __rsub__(int64 v) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeDifference(v, $self->Var());
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
IntExpr* __mul__(IntExpr* other) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeProd($self->Var(), other);
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
IntExpr* __mul__(Constraint* other) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeProd($self->Var(), other->Var());
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
IntExpr* __mul__(int64 v) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeProd($self->Var(), v);
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
IntExpr* __rmul__(int64 v) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeProd($self->Var(), v);
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
IntExpr* __floordiv__(int64 v) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeDiv($self->Var(), v);
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IntExpr* __neg__() {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeOpposite($self->Var());
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
IntExpr* __abs__() {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeAbs($self->Var());
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
IntExpr* Square() {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeSquare($self->Var());
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Constraint* __eq__(int64 v) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeEquality($self->Var(), v);
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
Constraint* __ne__(int64 v) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeNonEquality($self->Var(), v);
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
Constraint* __ge__(int64 v) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeGreaterOrEqual($self->Var(), v);
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
Constraint* __gt__(int64 v) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeGreater($self->Var(), v);
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
Constraint* __le__(int64 v) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeLessOrEqual($self->Var(), v);
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
Constraint* __lt__(int64 v) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeLess($self->Var(), v);
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
Constraint* __eq__(IntExpr* other) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeEquality($self->Var(), other->Var());
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
Constraint* __ne__(IntExpr* other) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeNonEquality($self->Var(), other->Var());
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
Constraint* __ge__(IntExpr* other) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeGreaterOrEqual($self->Var(), other->Var());
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
Constraint* __gt__(IntExpr* other) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeGreater($self->Var(), other->Var());
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
Constraint* __le__(IntExpr* other) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeLessOrEqual($self->Var(), other->Var());
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
Constraint* __lt__(IntExpr* other) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeLess($self->Var(), other->Var());
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
Constraint* __eq__(Constraint* other) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeEquality($self->Var(), other->Var());
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
Constraint* __ne__(Constraint* other) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeNonEquality($self->Var(), other->Var());
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
Constraint* __ge__(Constraint* other) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeGreaterOrEqual($self->Var(), other->Var());
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
Constraint* __gt__(Constraint* other) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeGreater($self->Var(), other->Var());
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
Constraint* __le__(Constraint* other) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeLessOrEqual($self->Var(), other->Var());
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
Constraint* __lt__(Constraint* other) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeLess($self->Var(), other->Var());
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
Constraint* MapTo(const std::vector<IntVar*>& vars) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeMapDomain($self->Var(), vars);
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
IntExpr* IndexOf(const std::vector<int64>& vars) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeElement(vars, $self->Var());
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
IntExpr* IndexOf(const std::vector<IntVar*>& vars) {
|
2014-07-09 11:17:29 +00:00
|
|
|
return $self->solver()->MakeElement(vars, $self->Var());
|
2012-03-19 17:14:57 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-20 11:32:37 +01:00
|
|
|
// Add easy variable getters to BaseLns ([i] gets the value of variable #i).
|
|
|
|
|
%extend operations_research::BaseLns {
|
2014-07-09 11:17:29 +00:00
|
|
|
int64 __getitem__(int index) {
|
|
|
|
|
return $self->Value(index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int __len__() {
|
|
|
|
|
return $self->Size();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Extend IntVarIterator to make it iterable in python.
|
|
|
|
|
%extend operations_research::IntVarIterator {
|
2014-06-13 13:26:09 +00:00
|
|
|
%pythoncode {
|
|
|
|
|
def __iter__(self):
|
|
|
|
|
self.Init()
|
|
|
|
|
return self
|
|
|
|
|
|
|
|
|
|
def next(self):
|
|
|
|
|
if self.Ok():
|
|
|
|
|
result = self.Value()
|
|
|
|
|
self.Next()
|
|
|
|
|
return result
|
|
|
|
|
else:
|
|
|
|
|
raise StopIteration()
|
2015-12-11 14:29:37 +01:00
|
|
|
|
|
|
|
|
def __next__(self):
|
|
|
|
|
if self.Ok():
|
|
|
|
|
result = self.Value()
|
|
|
|
|
self.Next()
|
|
|
|
|
return result
|
|
|
|
|
else:
|
|
|
|
|
raise StopIteration()
|
2014-07-09 11:17:29 +00:00
|
|
|
} // %pythoncode
|
2014-06-13 13:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
2014-07-09 11:17:29 +00:00
|
|
|
// Extend IntVar to provide natural iteration over its domains.
|
|
|
|
|
%extend operations_research::IntVar {
|
2014-06-13 13:26:09 +00:00
|
|
|
%pythoncode {
|
|
|
|
|
def DomainIterator(self):
|
|
|
|
|
return iter(self.DomainIteratorAux(False))
|
|
|
|
|
|
|
|
|
|
def HoleIterator(self):
|
|
|
|
|
return iter(self.HoleIteratorAux(False))
|
2014-07-09 11:17:29 +00:00
|
|
|
} // %pythoncode
|
2014-06-13 13:26:09 +00:00
|
|
|
}
|
|
|
|
|
|
2014-07-09 11:17:29 +00:00
|
|
|
%extend operations_research::IntVarLocalSearchFilter {
|
2014-06-15 21:02:58 +00:00
|
|
|
int64 IndexFromVar(IntVar* const var) const {
|
|
|
|
|
int64 index = -1;
|
2014-07-09 11:17:29 +00:00
|
|
|
$self->FindIndex(var, &index);
|
2014-06-15 20:41:43 +00:00
|
|
|
return index;
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-07-09 11:17:29 +00:00
|
|
|
|
2010-10-08 23:55:59 +00:00
|
|
|
|
2014-06-13 10:03:03 +00:00
|
|
|
// ############ BEGIN DUPLICATED CODE BLOCK ############
|
|
|
|
|
// IMPORTANT: keep this code block in sync with the .swig
|
|
|
|
|
// files in ../java and ../csharp.
|
2014-07-09 11:17:29 +00:00
|
|
|
// TODO(user): extract this duplicated code into a common, multi-language
|
|
|
|
|
// .swig file with SWIG_exception.
|
2014-06-13 10:03:03 +00:00
|
|
|
|
|
|
|
|
// Protect from failure.
|
2014-07-09 11:17:29 +00:00
|
|
|
// TODO(user): document this further.
|
2013-12-10 16:02:46 +00:00
|
|
|
%define PROTECT_FROM_FAILURE(Method, GetSolver)
|
|
|
|
|
%exception Method {
|
|
|
|
|
operations_research::Solver* const solver = GetSolver;
|
|
|
|
|
FailureProtect protect;
|
2015-05-04 17:30:16 +02:00
|
|
|
solver->set_fail_intercept([&protect]() { protect.JumpBack(); });
|
2010-10-08 23:55:59 +00:00
|
|
|
if (setjmp(protect.exception_buffer) == 0) {
|
|
|
|
|
$action
|
2013-12-10 16:02:46 +00:00
|
|
|
solver->clear_fail_intercept();
|
|
|
|
|
} else {
|
|
|
|
|
solver->clear_fail_intercept();
|
2014-07-09 11:17:29 +00:00
|
|
|
// IMPORTANT: the type and message of the exception raised matter,
|
|
|
|
|
// because they are caught by the python overrides of some CP classes.
|
2014-07-24 18:27:32 +00:00
|
|
|
// See the occurrences of the "PyExc_Exception" std::string below.
|
2014-07-09 11:17:29 +00:00
|
|
|
PyErr_SetString(PyExc_Exception, "CP Solver fail");
|
2013-12-10 16:02:46 +00:00
|
|
|
SWIG_fail;
|
|
|
|
|
}
|
2010-10-09 00:01:02 +00:00
|
|
|
}
|
2013-12-10 16:02:46 +00:00
|
|
|
%enddef
|
2014-07-09 11:17:29 +00:00
|
|
|
|
2013-12-10 16:02:46 +00:00
|
|
|
namespace operations_research {
|
|
|
|
|
PROTECT_FROM_FAILURE(IntExpr::SetValue(int64 v), arg1->solver());
|
|
|
|
|
PROTECT_FROM_FAILURE(IntExpr::SetMin(int64 v), arg1->solver());
|
|
|
|
|
PROTECT_FROM_FAILURE(IntExpr::SetMax(int64 v), arg1->solver());
|
|
|
|
|
PROTECT_FROM_FAILURE(IntExpr::SetRange(int64 mi, int64 ma), arg1->solver());
|
|
|
|
|
PROTECT_FROM_FAILURE(IntVar::RemoveValue(int64 v), arg1->solver());
|
|
|
|
|
PROTECT_FROM_FAILURE(IntVar::RemoveValues(const std::vector<int64>& values),
|
|
|
|
|
arg1->solver());
|
|
|
|
|
PROTECT_FROM_FAILURE(IntervalVar::SetStartMin(int64 m), arg1->solver());
|
|
|
|
|
PROTECT_FROM_FAILURE(IntervalVar::SetStartMax(int64 m), arg1->solver());
|
|
|
|
|
PROTECT_FROM_FAILURE(IntervalVar::SetStartRange(int64 mi, int64 ma),
|
|
|
|
|
arg1->solver());
|
|
|
|
|
PROTECT_FROM_FAILURE(IntervalVar::SetDurationMin(int64 m), arg1->solver());
|
|
|
|
|
PROTECT_FROM_FAILURE(IntervalVar::SetDurationMax(int64 m), arg1->solver());
|
|
|
|
|
PROTECT_FROM_FAILURE(IntervalVar::SetDurationRange(int64 mi, int64 ma),
|
|
|
|
|
arg1->solver());
|
|
|
|
|
PROTECT_FROM_FAILURE(IntervalVar::SetEndMin(int64 m), arg1->solver());
|
|
|
|
|
PROTECT_FROM_FAILURE(IntervalVar::SetEndMax(int64 m), arg1->solver());
|
|
|
|
|
PROTECT_FROM_FAILURE(IntervalVar::SetEndRange(int64 mi, int64 ma),
|
|
|
|
|
arg1->solver());
|
|
|
|
|
PROTECT_FROM_FAILURE(IntervalVar::SetPerformed(bool val), arg1->solver());
|
|
|
|
|
PROTECT_FROM_FAILURE(Solver::AddConstraint(Constraint* const ct), arg1);
|
|
|
|
|
PROTECT_FROM_FAILURE(Solver::Fail(), arg1);
|
2010-09-15 12:42:33 +00:00
|
|
|
} // namespace operations_research
|
2014-07-09 11:17:29 +00:00
|
|
|
#undef PROTECT_FROM_FAILURE
|
2010-09-15 12:42:33 +00:00
|
|
|
|
2014-06-13 10:03:03 +00:00
|
|
|
// ############ END DUPLICATED CODE BLOCK ############
|
|
|
|
|
|
2014-07-09 11:17:29 +00:00
|
|
|
// ============= Exposed C++ API : Solver class ==============
|
|
|
|
|
|
|
|
|
|
%ignoreall
|
|
|
|
|
|
|
|
|
|
%unignore operations_research;
|
|
|
|
|
|
|
|
|
|
namespace operations_research {
|
|
|
|
|
|
|
|
|
|
// Solver: Basic API.
|
|
|
|
|
%unignore Solver;
|
|
|
|
|
%unignore Solver::Solver;
|
|
|
|
|
%unignore Solver::~Solver;
|
2016-01-05 22:35:02 +01:00
|
|
|
%unignore Solver::AddConstraint;
|
2014-07-09 11:17:29 +00:00
|
|
|
%unignore Solver::Solve;
|
|
|
|
|
|
|
|
|
|
// Solver: Decomposed or specialized Solve() API.
|
|
|
|
|
%unignore Solver::NewSearch;
|
|
|
|
|
%unignore Solver::NextSolution;
|
|
|
|
|
%unignore Solver::RestartSearch;
|
|
|
|
|
%unignore Solver::EndSearch;
|
|
|
|
|
%unignore Solver::Fail;
|
|
|
|
|
%unignore Solver::SolveAndCommit;
|
|
|
|
|
%unignore Solver::FinishCurrentSearch;
|
|
|
|
|
%unignore Solver::RestartCurrentSearch;
|
2015-11-20 11:32:37 +01:00
|
|
|
%unignore Solver::AddBacktrackAction;
|
2014-07-09 11:17:29 +00:00
|
|
|
|
|
|
|
|
// Solver: Debug and performance counters.
|
|
|
|
|
%rename (WallTime) Solver::wall_time;
|
|
|
|
|
%rename (Branches) Solver::branches;
|
|
|
|
|
%rename (Solutions) Solver::solutions;
|
|
|
|
|
%rename (Failures) Solver::failures;
|
|
|
|
|
%rename (AcceptedNeighbors) Solver::accepted_neighbors;
|
|
|
|
|
%rename (Stamp) Solver::stamp;
|
|
|
|
|
%rename (FailStamp) Solver::fail_stamp;
|
|
|
|
|
%unignore Solver::SearchDepth;
|
|
|
|
|
%unignore Solver::SearchLeftDepth;
|
|
|
|
|
%unignore Solver::SolveDepth;
|
|
|
|
|
%rename (Constraints) Solver::constraints;
|
|
|
|
|
%unignore Solver::CheckAssignment;
|
|
|
|
|
%unignore Solver::CheckConstraint;
|
2014-07-23 05:48:13 +00:00
|
|
|
%unignore Solver::MemoryUsage;
|
2014-07-09 11:17:29 +00:00
|
|
|
|
|
|
|
|
// Solver: IntVar creation. We always strip the "Make" prefix in python.
|
|
|
|
|
%rename (IntVar) Solver::MakeIntVar;
|
|
|
|
|
%rename (BoolVar) Solver::MakeBoolVar;
|
|
|
|
|
%rename (IntConst) Solver::MakeIntConst;
|
|
|
|
|
|
|
|
|
|
// Solver: IntExpr creation. Most methods creating IntExpr are not exposed
|
|
|
|
|
// directly in python, but rather via the "Natural language" API. See examples.
|
|
|
|
|
%rename (Sum) Solver::MakeSum(const std::vector<IntVar*>&);
|
|
|
|
|
%rename (ScalProd) Solver::MakeScalProd;
|
|
|
|
|
%rename (Max) Solver::MakeMax;
|
|
|
|
|
%rename (Min) Solver::MakeMin;
|
|
|
|
|
%rename (SemiContinuousExpr) Solver::MakeSemiContinuousExpr;
|
|
|
|
|
%rename (MonotonicElement) Solver::MakeMonotonicElement;
|
2014-11-07 14:30:53 +00:00
|
|
|
%rename (IndexExpression) Solver::MakeIndexExpression;
|
2014-07-09 11:17:29 +00:00
|
|
|
%rename (ConvexPiecewiseExpr) Solver::MakeConvexPiecewiseExpr;
|
|
|
|
|
%rename (ConditionalExpression) Solver::MakeConditionalExpression;
|
2014-07-22 17:46:28 +00:00
|
|
|
%rename (Element) Solver::MakeElement;
|
2014-07-09 11:17:29 +00:00
|
|
|
|
|
|
|
|
// Solver: Basic constraints.
|
|
|
|
|
%rename (TrueConstraint) Solver::MakeTrueConstraint;
|
|
|
|
|
%rename (FalseConstraint) Solver::MakeFalseConstraint;
|
|
|
|
|
%rename (AllDifferent) Solver::MakeAllDifferent;
|
|
|
|
|
%rename (AllDifferentExcept) Solver::MakeAllDifferentExcept;
|
|
|
|
|
%rename (AllowedAssignments) Solver::MakeAllowedAssignments;
|
|
|
|
|
%rename (BetweenCt) Solver::MakeBetweenCt;
|
|
|
|
|
%rename (DisjunctiveConstraint) Solver::MakeDisjunctiveConstraint;
|
|
|
|
|
%rename (Distribute) Solver::MakeDistribute;
|
|
|
|
|
%rename (Cumulative) Solver::MakeCumulative;
|
|
|
|
|
|
2014-07-22 17:46:28 +00:00
|
|
|
// Solver: Constraints extracted from expressions.
|
|
|
|
|
%rename (SumLessOrEqual) Solver::MakeSumLessOrEqual;
|
|
|
|
|
%rename (SumGreaterOrEqual) Solver::MakeSumGreaterOrEqual;
|
|
|
|
|
%rename (SumEquality) Solver::MakeSumEquality;
|
|
|
|
|
%rename (ScalProdEquality) Solver::MakeScalProdEquality;
|
|
|
|
|
%rename (ScalProdGreaterOrEqual) Solver::MakeScalProdGreaterOrEqual;
|
|
|
|
|
%rename (ScalProdLessOrEqual) Solver::MakeScalProdLessOrEqual;
|
|
|
|
|
%rename (MinEquality) Solver::MakeMinEquality;
|
|
|
|
|
%rename (MaxEquality) Solver::MakeMaxEquality;
|
|
|
|
|
%rename (ElementEquality) Solver::MakeElementEquality;
|
|
|
|
|
%rename (AbsEquality) Solver::MakeAbsEquality;
|
|
|
|
|
%rename (IndexOfConstraint) Solver::MakeIndexOfConstraint;
|
|
|
|
|
|
2014-07-09 11:17:29 +00:00
|
|
|
// Solver: Constraints about interval variables.
|
|
|
|
|
%rename (FixedDurationIntervalVar) Solver::MakeFixedDurationIntervalVar;
|
2015-09-18 10:14:06 +02:00
|
|
|
%rename (IntervalVar) Solver::MakeIntervalVar;
|
2014-07-09 11:17:29 +00:00
|
|
|
%rename (FixedInterval) Solver::MakeFixedInterval;
|
|
|
|
|
%rename (MirrorInterval) Solver::MakeMirrorInterval;
|
|
|
|
|
%rename (FixedDurationStartSyncedOnStartIntervalVar)
|
|
|
|
|
Solver::MakeFixedDurationStartSyncedOnStartIntervalVar;
|
2015-12-16 19:51:09 +01:00
|
|
|
%rename (FixedDurationStartSyncedOnEndIntervalVar)
|
|
|
|
|
Solver::MakeFixedDurationStartSyncedOnEndIntervalVar;
|
|
|
|
|
%rename (FixedDurationEndSyncedOnStartIntervalVar)
|
|
|
|
|
Solver::MakeFixedDurationEndSyncedOnStartIntervalVar;
|
2014-07-09 11:17:29 +00:00
|
|
|
%rename (FixedDurationEndSyncedOnEndIntervalVar)
|
|
|
|
|
Solver::MakeFixedDurationEndSyncedOnEndIntervalVar;
|
|
|
|
|
%rename (IntervalRelaxedMin) Solver::MakeIntervalRelaxedMin;
|
|
|
|
|
%rename (IntervalRelaxedMax) Solver::MakeIntervalRelaxedMax;
|
|
|
|
|
%rename (TemporalDisjunction) Solver::MakeTemporalDisjunction;
|
|
|
|
|
%rename (Cover) Solver::MakeCover;
|
|
|
|
|
|
|
|
|
|
// Solver: Constraints tying a boolean var to an expression. Model-wise; it is
|
|
|
|
|
// equivalent to creating the expression via the python natural API; and then
|
|
|
|
|
// declaring its equality to the boolean var.
|
2014-07-22 17:53:38 +00:00
|
|
|
%rename (IsEqualCstVar) Solver::MakeIsEqualCstVar;
|
|
|
|
|
%rename (IsEqualVar) Solver::MakeIsEqualVar;
|
2014-07-24 18:27:32 +00:00
|
|
|
%rename (IsDifferentCstVar) Solver::MakeIsDifferentCstVar;
|
|
|
|
|
%rename (IsDifferentVar) Solver::MakeIsDifferentVar;
|
2014-07-22 17:53:38 +00:00
|
|
|
%rename (IsGreaterCstVar) Solver::MakeIsGreaterCstVar;
|
|
|
|
|
%rename (IsGreaterVar) Solver::MakeIsGreaterVar;
|
|
|
|
|
%rename (IsLessCstVar) Solver::MakeIsLessCstVar;
|
2014-07-24 18:27:32 +00:00
|
|
|
%rename (IsLessVar) Solver::MakeIsLessVar;
|
|
|
|
|
%rename (IsGreaterOrEqualCstVar) Solver::MakeIsGreaterOrEqualCstVar;
|
|
|
|
|
%rename (IsGreaterOrEqualVar) Solver::MakeIsGreaterOrEqualVar;
|
2014-07-22 17:53:38 +00:00
|
|
|
%rename (IsLessOrEqualCstVar) Solver::MakeIsLessOrEqualCstVar;
|
|
|
|
|
%rename (IsLessOrEqualVar) Solver::MakeIsLessOrEqualVar;
|
2014-07-24 18:27:32 +00:00
|
|
|
%rename (IsBetweenVar) Solver::MakeIsBetweenVar;
|
2014-07-22 17:53:38 +00:00
|
|
|
%rename (IsMemberVar) Solver::MakeIsMemberVar;
|
2014-07-09 11:17:29 +00:00
|
|
|
// The methods below should be avoided: use the *Var versions above if you can.
|
2014-07-22 17:53:38 +00:00
|
|
|
%rename (IsEqualCstCt) Solver::MakeIsEqualCstCt;
|
|
|
|
|
%rename (IsEqualCt) Solver::MakeIsEqualCt;
|
2014-07-24 18:27:32 +00:00
|
|
|
%rename (IsDifferentCstCt) Solver::MakeIsDifferentCstCt;
|
|
|
|
|
%rename (IsDifferentCt) Solver::MakeIsDifferentCt;
|
2014-07-22 17:53:38 +00:00
|
|
|
%rename (IsGreaterCstCt) Solver::MakeIsGreaterCstCt;
|
|
|
|
|
%rename (IsGreaterCt) Solver::MakeIsGreaterCt;
|
|
|
|
|
%rename (IsLessCstCt) Solver::MakeIsLessCstCt;
|
2014-07-09 11:17:29 +00:00
|
|
|
%rename (IsLessCt) Solver::MakeIsLessCt;
|
2014-07-24 18:27:32 +00:00
|
|
|
%rename (IsGreaterOrEqualCstCt) Solver::MakeIsGreaterOrEqualCstCt;
|
|
|
|
|
%rename (IsGreaterOrEqualCt) Solver::MakeIsGreaterOrEqualCt;
|
2014-07-22 17:53:38 +00:00
|
|
|
%rename (IsLessOrEqualCstCt) Solver::MakeIsLessOrEqualCstCt;
|
|
|
|
|
%rename (IsLessOrEqualCt) Solver::MakeIsLessOrEqualCt;
|
2014-07-24 18:27:32 +00:00
|
|
|
%rename (IsBetweenCt) Solver::MakeIsBetweenCt;
|
2014-07-22 17:53:38 +00:00
|
|
|
%rename (IsMemberCt) Solver::MakeIsMemberCt;
|
|
|
|
|
|
2014-07-09 11:17:29 +00:00
|
|
|
|
|
|
|
|
// Solver: Elaborate constraint creation.
|
|
|
|
|
%rename (Count) Solver::MakeCount;
|
|
|
|
|
%rename (Deviation) Solver::MakeDeviation;
|
|
|
|
|
%rename (SortingConstraint) Solver::MakeSortingConstraint;
|
|
|
|
|
%rename (LexicalLess) Solver::MakeLexicalLess;
|
|
|
|
|
%rename (LexicalLessOrEqual) Solver::MakeLexicalLessOrEqual;
|
|
|
|
|
%rename (InversePermutationConstraint) Solver::MakeInversePermutationConstraint;
|
|
|
|
|
%rename (NullIntersect) Solver::MakeNullIntersect;
|
|
|
|
|
%rename (NullIntersectExcept) Solver::MakeNullIntersectExcept;
|
|
|
|
|
%rename (Circuit) Solver::MakeCircuit;
|
2014-07-22 19:09:57 +00:00
|
|
|
%rename (MemberCt) Solver::MakeMemberCt;
|
2014-07-09 11:17:29 +00:00
|
|
|
%rename (SubCircuit) Solver::MakeSubCircuit;
|
|
|
|
|
%rename (PathCumul) Solver::MakePathCumul;
|
|
|
|
|
%rename (DelayedPathCumul) Solver::MakeDelayedPathCumul;
|
|
|
|
|
%rename (TransitionConstraint) Solver::MakeTransitionConstraint;
|
|
|
|
|
%rename (NonOverlappingBoxesConstraint)
|
|
|
|
|
Solver::MakeNonOverlappingBoxesConstraint;
|
|
|
|
|
%rename (Pack) Solver::MakePack;
|
|
|
|
|
|
|
|
|
|
// Solver: Other object creation.
|
|
|
|
|
%rename (Assignment) Solver::MakeAssignment;
|
|
|
|
|
|
|
|
|
|
// Solver: Demon creation and demon-related methods.
|
|
|
|
|
%unignore Solver::ShouldFail;
|
|
|
|
|
%rename (ConstraintInitialPropagateCallback)
|
|
|
|
|
Solver::MakeConstraintInitialPropagateCallback;
|
|
|
|
|
%rename (DelayedConstraintInitialPropagateCallback)
|
|
|
|
|
Solver::MakeDelayedConstraintInitialPropagateCallback;
|
2015-11-20 11:32:37 +01:00
|
|
|
%rename (ActionDemon) Solver::MakeActionDemon;
|
|
|
|
|
%rename (ClosureDemon) Solver::MakeClosureDemon;
|
2014-07-09 11:17:29 +00:00
|
|
|
|
|
|
|
|
// Solver: Solution Collectors
|
|
|
|
|
%rename (BestValueSolutionCollector) Solver::MakeBestValueSolutionCollector;
|
|
|
|
|
%rename (FirstSolutionCollector) Solver::MakeFirstSolutionCollector;
|
|
|
|
|
%rename (LastSolutionCollector) Solver::MakeLastSolutionCollector;
|
|
|
|
|
%rename (AllSolutionCollector) Solver::MakeAllSolutionCollector;
|
|
|
|
|
|
|
|
|
|
// Solver: Objective variables, i.e. OptimizeVar creation.
|
|
|
|
|
%rename (Minimize) Solver::MakeMinimize;
|
|
|
|
|
%rename (Maximize) Solver::MakeMaximize;
|
|
|
|
|
%rename (Optimize) Solver::MakeOptimize;
|
|
|
|
|
%rename (WeightedMinimize) Solver::MakeWeightedMinimize;
|
|
|
|
|
%rename (WeightedMaximize) Solver::MakeWeightedMaximize;
|
|
|
|
|
%rename (WeightedOptimize) Solver::MakeWeightedOptimize;
|
|
|
|
|
|
|
|
|
|
// Solver: Meta-heuristics.
|
|
|
|
|
%rename (TabuSearch) Solver::MakeTabuSearch;
|
|
|
|
|
%rename (SimulatedAnnealing) Solver::MakeSimulatedAnnealing;
|
|
|
|
|
%rename (GuidedLocalSearch) Solver::MakeGuidedLocalSearch;
|
|
|
|
|
%rename (LubyRestart) Solver::MakeLubyRestart;
|
|
|
|
|
%rename (ConstantRestart) Solver::MakeConstantRestart;
|
|
|
|
|
|
|
|
|
|
// Solver: Search Limits.
|
|
|
|
|
%unignore Solver::SearchLimitProto; // search_limit.proto
|
|
|
|
|
%rename (Limit) Solver::MakeLimit;
|
|
|
|
|
%rename (TimeLimit) Solver::MakeTimeLimit;
|
2014-07-22 19:28:00 +00:00
|
|
|
%rename (BranchesLimit) Solver::MakeBranchesLimit;
|
|
|
|
|
%rename (FailuresLimit) Solver::MakeFailuresLimit;
|
2014-07-09 11:17:29 +00:00
|
|
|
%rename (SolutionsLimit) Solver::MakeSolutionsLimit;
|
|
|
|
|
%rename (CustomLimit) Solver::MakeCustomLimit;
|
|
|
|
|
|
|
|
|
|
// Solver: Search logs.
|
|
|
|
|
%rename (SearchLog) Solver::MakeSearchLog;
|
|
|
|
|
%rename (SearchTrace) Solver::MakeSearchTrace;
|
2016-01-05 11:04:11 +01:00
|
|
|
%rename (TreeMonitor) Solver::MakeTreeMonitor;
|
2014-07-09 11:17:29 +00:00
|
|
|
|
|
|
|
|
// Solver: Model visitors.
|
|
|
|
|
%unignore Solver::Accept;
|
|
|
|
|
%rename (PrintModelVisitor) Solver::MakePrintModelVisitor;
|
|
|
|
|
%rename (StatisticsModelVisitor) Solver::MakeStatisticsModelVisitor;
|
|
|
|
|
|
|
|
|
|
// Solver: Decisions
|
|
|
|
|
%rename (SplitVariableDomain) Solver::MakeSplitVariableDomain;
|
|
|
|
|
%rename (AssignVariableValue) Solver::MakeAssignVariableValue;
|
|
|
|
|
%rename (VariableLessOrEqualValue) Solver::MakeVariableLessOrEqualValue;
|
|
|
|
|
%rename (VariableGreaterOrEqualValue) Solver::MakeVariableGreaterOrEqualValue;
|
|
|
|
|
%rename (AssignVariableValueOrFail) Solver::MakeAssignVariableValueOrFail;
|
|
|
|
|
%rename (AssignVariablesValues) Solver::MakeAssignVariablesValues;
|
|
|
|
|
%rename (FailDecision) Solver::MakeFailDecision;
|
2015-11-20 11:32:37 +01:00
|
|
|
%rename (Decision) Solver::MakeDecision;
|
2014-07-09 11:17:29 +00:00
|
|
|
|
|
|
|
|
// Solver: Decision builders. Many versions of MakePhase() are not exposed
|
|
|
|
|
// directly; instead there are python-specific shortcuts provided above.
|
|
|
|
|
// See the occurrences of "DecisionBuilder*" in this file.
|
|
|
|
|
%unignore Solver::Try(const std::vector<DecisionBuilder*>&);
|
|
|
|
|
%unignore Solver::Compose(const std::vector<DecisionBuilder*>&);
|
|
|
|
|
%rename (SolveOnce) Solver::MakeSolveOnce(DecisionBuilder* const,
|
|
|
|
|
const std::vector<SearchMonitor*>&);
|
|
|
|
|
%rename (Phase) Solver::MakePhase(const std::vector<IntVar*>&,
|
|
|
|
|
IntVarStrategy, IntValueStrategy);
|
|
|
|
|
%rename (Phase) Solver::MakePhase(const std::vector<IntervalVar*>&,
|
|
|
|
|
IntervalStrategy);
|
|
|
|
|
%rename (Phase) Solver::MakePhase(const std::vector<SequenceVar*>&,
|
|
|
|
|
SequenceStrategy);
|
|
|
|
|
%rename (DefaultPhase) Solver::MakeDefaultPhase;
|
|
|
|
|
%rename (LocalSearchPhase) Solver::MakeLocalSearchPhase;
|
|
|
|
|
%rename (ScheduleOrPostpone) Solver::MakeScheduleOrPostpone;
|
|
|
|
|
%rename (ScheduleOrExpedite) Solver::MakeScheduleOrExpedite;
|
|
|
|
|
%rename (RankFirstInterval) Solver::MakeRankFirstInterval;
|
|
|
|
|
%rename (RankLastInterval) Solver::MakeRankLastInterval;
|
|
|
|
|
%rename (DecisionBuilderFromAssignment)
|
|
|
|
|
Solver::MakeDecisionBuilderFromAssignment;
|
|
|
|
|
%rename (ConstraintAdder) Solver::MakeConstraintAdder;
|
|
|
|
|
%rename (NestedOptimize) Solver::MakeNestedOptimize;
|
|
|
|
|
%rename (StoreAssignment) Solver::MakeStoreAssignment;
|
|
|
|
|
%rename (RestoreAssignment) Solver::MakeRestoreAssignment;
|
|
|
|
|
|
|
|
|
|
// Solver: Local search operators.
|
|
|
|
|
%rename (Operator) Solver::MakeOperator;
|
2015-11-20 11:32:37 +01:00
|
|
|
%rename (RandomLnsOperator) Solver::MakeRandomLnsOperator;
|
2014-07-09 11:17:29 +00:00
|
|
|
%unignore Solver::ConcatenateOperators;
|
|
|
|
|
%unignore Solver::RandomConcatenateOperators;
|
|
|
|
|
%rename (LocalSearchPhaseParameters) Solver::MakeLocalSearchPhaseParameters;
|
|
|
|
|
%rename (MoveTowardTargetOperator) Solver::MakeMoveTowardTargetOperator;
|
|
|
|
|
%rename (NeighborhoodLimit) Solver::MakeNeighborhoodLimit;
|
|
|
|
|
|
2015-03-27 10:18:03 +01:00
|
|
|
// Random part.
|
2015-03-30 10:46:48 +02:00
|
|
|
%unignore Solver::Rand64;
|
|
|
|
|
%unignore Solver::Rand32;
|
|
|
|
|
%unignore Solver::ReSeed;
|
2015-03-27 10:18:03 +01:00
|
|
|
|
2014-07-09 11:17:29 +00:00
|
|
|
// Enums. Each section below exposes one enum, with all its exposed values.
|
|
|
|
|
%unignore Solver::IntVarStrategy;
|
|
|
|
|
%unignore Solver::INT_VAR_DEFAULT;
|
|
|
|
|
%unignore Solver::INT_VAR_SIMPLE;
|
|
|
|
|
%unignore Solver::CHOOSE_FIRST_UNBOUND;
|
|
|
|
|
%unignore Solver::CHOOSE_RANDOM;
|
|
|
|
|
%unignore Solver::CHOOSE_MIN_SIZE_LOWEST_MIN;
|
|
|
|
|
%unignore Solver::CHOOSE_MIN_SIZE_HIGHEST_MIN;
|
|
|
|
|
%unignore Solver::CHOOSE_MIN_SIZE_LOWEST_MAX;
|
|
|
|
|
%unignore Solver::CHOOSE_MIN_SIZE_HIGHEST_MAX;
|
|
|
|
|
%unignore Solver::CHOOSE_LOWEST_MIN;
|
|
|
|
|
%unignore Solver::CHOOSE_HIGHEST_MAX;
|
|
|
|
|
%unignore Solver::CHOOSE_MIN_SIZE;
|
|
|
|
|
%unignore Solver::CHOOSE_MAX_SIZE;
|
|
|
|
|
%unignore Solver::CHOOSE_MAX_REGRET_ON_MIN;
|
|
|
|
|
%unignore Solver::CHOOSE_PATH;
|
|
|
|
|
|
|
|
|
|
%unignore Solver::IntValueStrategy;
|
|
|
|
|
%unignore Solver::INT_VALUE_DEFAULT;
|
|
|
|
|
%unignore Solver::INT_VALUE_SIMPLE;
|
|
|
|
|
%unignore Solver::ASSIGN_MIN_VALUE;
|
|
|
|
|
%unignore Solver::ASSIGN_MAX_VALUE;
|
|
|
|
|
%unignore Solver::ASSIGN_RANDOM_VALUE;
|
|
|
|
|
%unignore Solver::ASSIGN_CENTER_VALUE;
|
|
|
|
|
%unignore Solver::SPLIT_LOWER_HALF;
|
|
|
|
|
%unignore Solver::SPLIT_UPPER_HALF;
|
|
|
|
|
|
|
|
|
|
%unignore Solver::SequenceStrategy;
|
|
|
|
|
%unignore Solver::SEQUENCE_DEFAULT;
|
|
|
|
|
%unignore Solver::SEQUENCE_SIMPLE;
|
|
|
|
|
%unignore Solver::CHOOSE_MIN_SLACK_RANK_FORWARD;
|
|
|
|
|
%unignore Solver::CHOOSE_RANDOM_RANK_FORWARD;
|
|
|
|
|
|
|
|
|
|
%unignore Solver::IntervalStrategy;
|
|
|
|
|
%unignore Solver::INTERVAL_DEFAULT;
|
|
|
|
|
%unignore Solver::INTERVAL_SIMPLE;
|
|
|
|
|
%unignore Solver::INTERVAL_SET_TIMES_FORWARD;
|
|
|
|
|
%unignore Solver::INTERVAL_SET_TIMES_BACKWARD;
|
|
|
|
|
|
|
|
|
|
%unignore Solver::LocalSearchOperators;
|
|
|
|
|
%unignore Solver::TWOOPT;
|
|
|
|
|
%unignore Solver::OROPT;
|
|
|
|
|
%unignore Solver::RELOCATE;
|
|
|
|
|
%unignore Solver::EXCHANGE;
|
|
|
|
|
%unignore Solver::CROSS;
|
|
|
|
|
%unignore Solver::MAKEACTIVE;
|
|
|
|
|
%unignore Solver::MAKEINACTIVE;
|
|
|
|
|
%unignore Solver::MAKECHAININACTIVE;
|
|
|
|
|
%unignore Solver::SWAPACTIVE;
|
|
|
|
|
%unignore Solver::EXTENDEDSWAPACTIVE;
|
|
|
|
|
%unignore Solver::PATHLNS;
|
|
|
|
|
%unignore Solver::FULLPATHLNS;
|
|
|
|
|
%unignore Solver::UNACTIVELNS;
|
|
|
|
|
%unignore Solver::INCREMENT;
|
|
|
|
|
%unignore Solver::DECREMENT;
|
|
|
|
|
%unignore Solver::SIMPLELNS;
|
|
|
|
|
|
|
|
|
|
%unignore Solver::LocalSearchFilterBound;
|
|
|
|
|
%unignore Solver::GE;
|
|
|
|
|
%unignore Solver::LE;
|
|
|
|
|
%unignore Solver::EQ;
|
|
|
|
|
|
|
|
|
|
%unignore Solver::LocalSearchOperation;
|
|
|
|
|
%unignore Solver::SUM;
|
|
|
|
|
%unignore Solver::PROD;
|
|
|
|
|
%unignore Solver::MAX;
|
|
|
|
|
%unignore Solver::MIN;
|
|
|
|
|
|
|
|
|
|
} // namespace operations_research
|
|
|
|
|
|
|
|
|
|
// ============= Unexposed C++ API : Solver class ==============
|
|
|
|
|
// TODO(user): remove this listing of unexposed methods (which was exhaustive
|
|
|
|
|
// as of 2014-07-01) when we are confident with the stability of the or-tools
|
|
|
|
|
// export. Until then, it is an extremely useful reference for development.
|
|
|
|
|
//
|
|
|
|
|
// Unexposed Solver:: methods (grouped semantically):
|
|
|
|
|
//
|
|
|
|
|
// - parameters()
|
|
|
|
|
// - SaveValue()
|
|
|
|
|
// - RevAlloc()
|
|
|
|
|
// - RevAllocArray()
|
|
|
|
|
//
|
|
|
|
|
// - AddCastConstraint()
|
|
|
|
|
//
|
|
|
|
|
// - state()
|
|
|
|
|
//
|
|
|
|
|
// - ExportModel()
|
|
|
|
|
// - LoadModel()
|
|
|
|
|
// - UpgradeModel()
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// - DebugString()
|
|
|
|
|
// - VirtualMemorySize()
|
|
|
|
|
// - SetClock()
|
|
|
|
|
//
|
|
|
|
|
// - demon_runs()
|
|
|
|
|
// - neighbors()
|
|
|
|
|
// - filtered_neighbors()
|
|
|
|
|
//
|
|
|
|
|
// - MakeIntVarArray()
|
|
|
|
|
// - MakeBoolVarArray()
|
|
|
|
|
//
|
|
|
|
|
// - MakeCallbackDemon()
|
2015-05-19 16:15:11 +02:00
|
|
|
// - MakeClosureDemon()
|
2014-07-09 11:17:29 +00:00
|
|
|
//
|
|
|
|
|
// - MakeFixedDurationIntervalVarArray()
|
|
|
|
|
// - MakeIntervalVarArray()
|
|
|
|
|
//
|
|
|
|
|
// - MakeEquality() // On IntervalVar.
|
|
|
|
|
//
|
|
|
|
|
// - UpdateLimits()
|
|
|
|
|
// - GetTime()
|
|
|
|
|
//
|
|
|
|
|
// - MakeNoGoodManager()
|
|
|
|
|
//
|
|
|
|
|
// - MakeVariableDegreeVisitor()
|
|
|
|
|
//
|
|
|
|
|
// - MakeSymmetryManager()
|
|
|
|
|
//
|
|
|
|
|
// - MakeSimplexConstraint()
|
|
|
|
|
//
|
|
|
|
|
// - MakeDefaultSolutionPool()
|
|
|
|
|
// - MakeVariableDomainFilter()
|
|
|
|
|
//
|
|
|
|
|
// - TopPeriodicCheck()
|
|
|
|
|
// - TopProgressPercent()
|
|
|
|
|
// - PushState()
|
|
|
|
|
// - PopState()
|
|
|
|
|
//
|
|
|
|
|
// - SetBranchSelector()
|
|
|
|
|
// - MakeApplyBranchSelector()
|
|
|
|
|
//
|
|
|
|
|
// - SaveAndSetValue()
|
|
|
|
|
// - SaveAndAdd()
|
|
|
|
|
//
|
|
|
|
|
// - ExportProfilingOverview()
|
|
|
|
|
// - CurrentlyInSolve()
|
|
|
|
|
// - balancing_decision()
|
|
|
|
|
// - set_fail_intercept()
|
|
|
|
|
// - clear_fail_intercept()
|
|
|
|
|
// - demon_profiler()
|
|
|
|
|
// - HasName()
|
|
|
|
|
//
|
|
|
|
|
// - RegisterDemon()
|
|
|
|
|
// - RegisterIntExpr()
|
|
|
|
|
// - RegisterIntVar()
|
|
|
|
|
// - RegisterIntervalVar()
|
|
|
|
|
//
|
|
|
|
|
// - ActiveSearch()
|
|
|
|
|
// - Cache()
|
|
|
|
|
// - InstrumentsDemons()
|
|
|
|
|
// - IsProfilingEnabled()
|
|
|
|
|
// - InstrumentsVariables()
|
|
|
|
|
// - NameAllVariables()
|
|
|
|
|
// - model_name()
|
|
|
|
|
// - Graph()
|
|
|
|
|
// - GetPropagationMonitor()
|
|
|
|
|
// - AddPropagationMonitor()
|
|
|
|
|
// - tmp_vector_
|
|
|
|
|
// - IsBooleanVar()
|
|
|
|
|
// - IsProduct()
|
|
|
|
|
// - CastExpression()
|
|
|
|
|
|
|
|
|
|
// Unexposed Solver enums:
|
|
|
|
|
// - EvaluatorLocalSearchOperators
|
|
|
|
|
// - DemonPriority
|
|
|
|
|
// - BinaryIntervalRelation (replaced by an ad-hoc API on IntervalVar).
|
|
|
|
|
// - UnaryIntervalRelation (ditto)
|
|
|
|
|
// - DecisionModification
|
|
|
|
|
// - MarkerType
|
|
|
|
|
// - SolverState
|
|
|
|
|
|
|
|
|
|
// ============= Exposed C++ API : classes other than "Solver" ==============
|
|
|
|
|
|
|
|
|
|
namespace operations_research {
|
|
|
|
|
|
|
|
|
|
// Unexposed top-level classes and methods:
|
|
|
|
|
// - Zero()
|
|
|
|
|
// - BaseObject
|
|
|
|
|
// - DecisionVisitor
|
|
|
|
|
// - ModelVisitor
|
|
|
|
|
// - CastConstraint
|
|
|
|
|
// - NumericalRev<>
|
|
|
|
|
// - RevArray<>
|
|
|
|
|
// - NumericalRevArray<>
|
|
|
|
|
// - NoGood
|
|
|
|
|
// - NoGoodManager
|
|
|
|
|
// - AssignmentElement
|
|
|
|
|
// - SolutionPool
|
|
|
|
|
|
|
|
|
|
// SolverParameters
|
|
|
|
|
// Ignored:
|
|
|
|
|
// - Constants:
|
|
|
|
|
// - kDefaultTrailCompression
|
|
|
|
|
// - kDefaultTrailBlockSize
|
|
|
|
|
// - kDefaultArraySplitSize
|
|
|
|
|
// - kDefaultNameStoring
|
|
|
|
|
// - kDefaultProfileLevel
|
|
|
|
|
// - kDefaultTraceLevel
|
|
|
|
|
// - kDefaultNameAllVariables
|
|
|
|
|
%unignore SolverParameters;
|
|
|
|
|
%unignore SolverParameters::SolverParameters;
|
|
|
|
|
|
|
|
|
|
// SolverParameters: Enums.
|
|
|
|
|
%unignore SolverParameters::TrailCompression;
|
|
|
|
|
%unignore SolverParameters::NO_COMPRESSION;
|
|
|
|
|
%unignore SolverParameters::COMPRESS_WITH_ZLIB;
|
|
|
|
|
%unignore SolverParameters::ProfileLevel;
|
|
|
|
|
%unignore SolverParameters::NO_PROFILING;
|
|
|
|
|
%unignore SolverParameters::NORMAL_PROFILING;
|
|
|
|
|
%unignore SolverParameters::TraceLevel;
|
|
|
|
|
%unignore SolverParameters::NO_TRACE;
|
|
|
|
|
%unignore SolverParameters::NORMAL_TRACE;
|
|
|
|
|
|
|
|
|
|
// SolverParameters: data members.
|
|
|
|
|
%unignore SolverParameters::compress_trail;
|
|
|
|
|
%unignore SolverParameters::trail_block_size;
|
|
|
|
|
%unignore SolverParameters::array_split_size;
|
|
|
|
|
%unignore SolverParameters::store_names;
|
|
|
|
|
%unignore SolverParameters::profile_level;
|
|
|
|
|
%unignore SolverParameters::trace_level;
|
|
|
|
|
%unignore SolverParameters::name_all_variables;
|
|
|
|
|
|
|
|
|
|
// DefaultPhaseParameters
|
|
|
|
|
// Ignored:
|
|
|
|
|
// - Constants:
|
|
|
|
|
// - kDefaultNumberOfSplits
|
|
|
|
|
// - kDefaultHeuristicPeriod
|
|
|
|
|
// - kDefaultHeuristicNumFailuresLimit
|
|
|
|
|
// - kDefaultSeed
|
|
|
|
|
// - kDefaultRestartLogSize
|
|
|
|
|
// - kDefaultUseNoGoods
|
|
|
|
|
%unignore DefaultPhaseParameters;
|
|
|
|
|
%unignore DefaultPhaseParameters::DefaultPhaseParameters;
|
|
|
|
|
|
|
|
|
|
// DefaultPhaseParameters: Enums.
|
|
|
|
|
%unignore DefaultPhaseParameters::VariableSelection;
|
|
|
|
|
%unignore DefaultPhaseParameters::CHOOSE_MAX_SUM_IMPACT;
|
|
|
|
|
%unignore DefaultPhaseParameters::CHOOSE_MAX_AVERAGE_IMPACT;
|
|
|
|
|
%unignore DefaultPhaseParameters::CHOOSE_MAX_VALUE_IMPACT;
|
|
|
|
|
%unignore DefaultPhaseParameters::ValueSelection;
|
|
|
|
|
%unignore DefaultPhaseParameters::SELECT_MIN_IMPACT;
|
|
|
|
|
%unignore DefaultPhaseParameters::SELECT_MAX_IMPACT;
|
|
|
|
|
%unignore DefaultPhaseParameters::DisplayLevel;
|
|
|
|
|
%unignore DefaultPhaseParameters::NONE;
|
|
|
|
|
%unignore DefaultPhaseParameters::NORMAL;
|
|
|
|
|
%unignore DefaultPhaseParameters::VERBOSE;
|
|
|
|
|
|
|
|
|
|
// DefaultPhaseParameters: data members.
|
|
|
|
|
%unignore DefaultPhaseParameters::var_selection_schema;
|
|
|
|
|
%unignore DefaultPhaseParameters::value_selection_schema;
|
|
|
|
|
%unignore DefaultPhaseParameters::initialization_splits;
|
|
|
|
|
%unignore DefaultPhaseParameters::run_all_heuristics;
|
|
|
|
|
%unignore DefaultPhaseParameters::heuristic_period;
|
|
|
|
|
%unignore DefaultPhaseParameters::heuristic_num_failures_limit;
|
|
|
|
|
%unignore DefaultPhaseParameters::persistent_impact;
|
|
|
|
|
%unignore DefaultPhaseParameters::random_seed;
|
|
|
|
|
%unignore DefaultPhaseParameters::restart_log_size;
|
|
|
|
|
%unignore DefaultPhaseParameters::display_level;
|
|
|
|
|
%unignore DefaultPhaseParameters::use_no_goods;
|
|
|
|
|
%unignore DefaultPhaseParameters::decision_builder;
|
|
|
|
|
|
|
|
|
|
// PropagationBaseObject
|
|
|
|
|
// Ignored:
|
|
|
|
|
// - PropagationBaseObject()
|
|
|
|
|
// - ~PropagationBaseObject()
|
|
|
|
|
// - DebugString()
|
|
|
|
|
// - FreezeQueue()
|
|
|
|
|
// - UnfreezeQueue()
|
|
|
|
|
// - EnqueueDelayedDemon()
|
|
|
|
|
// - EnqueueVar()
|
|
|
|
|
// - Execute()
|
|
|
|
|
// - ExecuteAll()
|
|
|
|
|
// - EnqueueAll()
|
|
|
|
|
// - set_queue_action_on_fail()
|
|
|
|
|
// - clear_queue_action_on_fail()
|
|
|
|
|
// - set_name()
|
|
|
|
|
// - HasName()
|
|
|
|
|
// - Basename()
|
2016-01-05 18:38:47 +01:00
|
|
|
|
|
|
|
|
%feature("director") BaseObject;
|
|
|
|
|
%unignore BaseObject;
|
|
|
|
|
%unignore BaseObject::BaseObject;
|
|
|
|
|
%unignore BaseObject::~BaseObject;
|
|
|
|
|
%unignore BaseObject::DebugString;
|
|
|
|
|
|
|
|
|
|
%feature("director") PropagationBaseObject;
|
2014-07-09 11:17:29 +00:00
|
|
|
%unignore PropagationBaseObject;
|
2016-01-05 18:38:47 +01:00
|
|
|
%unignore PropagationBaseObject::PropagationBaseObject;
|
|
|
|
|
%unignore PropagationBaseObject::~PropagationBaseObject;
|
2014-07-09 11:17:29 +00:00
|
|
|
%rename (Name) PropagationBaseObject::name;
|
2014-07-22 19:09:57 +00:00
|
|
|
%rename (solver) PropagationBaseObject::solver;
|
2016-01-05 18:38:47 +01:00
|
|
|
%unignore PropagationBaseObject::DebugString;
|
|
|
|
|
%feature("nodirector") PropagationBaseObject::BaseName;
|
2014-07-09 11:17:29 +00:00
|
|
|
|
|
|
|
|
// Decision
|
|
|
|
|
// Ignored:
|
|
|
|
|
// - DebugString()
|
|
|
|
|
// - Accept()
|
2015-12-07 13:27:18 +01:00
|
|
|
%feature ("director") Decision;
|
2014-07-09 11:17:29 +00:00
|
|
|
%unignore Decision;
|
|
|
|
|
%unignore Decision::Decision;
|
|
|
|
|
%unignore Decision::~Decision;
|
2015-12-07 13:27:18 +01:00
|
|
|
%rename (ApplyWrapper) Decision::Apply;
|
|
|
|
|
%rename (RefuteWrapper) Decision::Refute;
|
|
|
|
|
%feature("nodirector") Decision::Accept;
|
2014-07-09 11:17:29 +00:00
|
|
|
|
|
|
|
|
// DecisionBuilder
|
2015-12-07 13:05:16 +01:00
|
|
|
%feature("director") DecisionBuilder;
|
2014-07-09 11:17:29 +00:00
|
|
|
%unignore DecisionBuilder;
|
|
|
|
|
%unignore DecisionBuilder::DecisionBuilder;
|
|
|
|
|
%unignore DecisionBuilder::~DecisionBuilder;
|
2015-12-07 13:05:16 +01:00
|
|
|
%rename (NextWrapper) DecisionBuilder::Next;
|
|
|
|
|
%unignore DecisionBuilder::DebugString;
|
|
|
|
|
%feature("nodirector") DecisionBuilder::Accept;
|
|
|
|
|
%feature("nodirector") DecisionBuilder::AppendMonitors;
|
2014-07-09 11:17:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
// Constraint
|
|
|
|
|
// Ignored:
|
|
|
|
|
// - Accept()
|
|
|
|
|
// - IsCastConstraint()
|
|
|
|
|
// Note(user): we prefer setting the 'director' feature on the individual
|
|
|
|
|
// methods of a class that require it, but sometimes we must actually set
|
|
|
|
|
// 'director' on the class itself, because it is a C++ abstract class and
|
|
|
|
|
// the client needs to construct it. In these cases, we don't bother
|
|
|
|
|
// setting the 'director' feature on individual methods, since it is done
|
|
|
|
|
// automatically when setting it on the class.
|
2016-01-05 18:38:47 +01:00
|
|
|
%unignore Constraint;
|
2014-07-09 11:17:29 +00:00
|
|
|
%feature("director") Constraint;
|
|
|
|
|
%unignore Constraint::Constraint;
|
|
|
|
|
%unignore Constraint::~Constraint;
|
|
|
|
|
%unignore Constraint::Post;
|
2016-01-05 18:38:47 +01:00
|
|
|
//%unignore Constraint::InitialPropagate;
|
2014-07-09 11:17:29 +00:00
|
|
|
%rename (InitialPropagateWrapper) Constraint::InitialPropagate;
|
2016-01-05 18:38:47 +01:00
|
|
|
%unignore Constraint::Var;
|
2015-12-07 13:05:16 +01:00
|
|
|
%unignore Constraint::DebugString;
|
2014-07-09 11:17:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
// SearchMonitor.
|
|
|
|
|
// Ignored:
|
|
|
|
|
// - kNoProgress
|
|
|
|
|
// - PeriodicCheck()
|
|
|
|
|
// - ProgressPercent()
|
|
|
|
|
// - Accept()
|
|
|
|
|
// - Install()
|
2015-01-13 10:52:12 +00:00
|
|
|
%feature("director") SearchMonitor;
|
2014-07-09 11:17:29 +00:00
|
|
|
%unignore SearchMonitor;
|
|
|
|
|
%unignore SearchMonitor::SearchMonitor;
|
|
|
|
|
%unignore SearchMonitor::~SearchMonitor;
|
|
|
|
|
%unignore SearchMonitor::EnterSearch;
|
2015-08-13 16:00:54 +02:00
|
|
|
%feature("director") SearchMonitor::EnterSearch;
|
2014-07-09 11:17:29 +00:00
|
|
|
%unignore SearchMonitor::RestartSearch;
|
2015-08-13 16:00:54 +02:00
|
|
|
%feature("director") SearchMonitor::RestartSearch;
|
2014-07-09 11:17:29 +00:00
|
|
|
%unignore SearchMonitor::ExitSearch;
|
2015-08-13 16:00:54 +02:00
|
|
|
%feature("director") SearchMonitor::ExitSearch;
|
2014-07-09 11:17:29 +00:00
|
|
|
%unignore SearchMonitor::BeginNextDecision;
|
2015-08-13 16:00:54 +02:00
|
|
|
%feature("director") SearchMonitor::BeginNextDecision;
|
2014-07-09 11:17:29 +00:00
|
|
|
%unignore SearchMonitor::EndNextDecision;
|
2015-08-13 16:00:54 +02:00
|
|
|
%feature("director") SearchMonitor::EndNextDecision;
|
2014-07-09 11:17:29 +00:00
|
|
|
%unignore SearchMonitor::ApplyDecision;
|
2015-08-13 16:00:54 +02:00
|
|
|
%feature("director") SearchMonitor::ApplyDecision;
|
2014-07-09 11:17:29 +00:00
|
|
|
%unignore SearchMonitor::RefuteDecision;
|
2015-08-13 16:00:54 +02:00
|
|
|
%feature("director") SearchMonitor::RefuteDecision;
|
2014-07-09 11:17:29 +00:00
|
|
|
%unignore SearchMonitor::AfterDecision;
|
2015-08-13 16:00:54 +02:00
|
|
|
%feature("director") SearchMonitor::AfterDecision;
|
2014-07-09 11:17:29 +00:00
|
|
|
%unignore SearchMonitor::BeginFail;
|
2015-08-13 16:00:54 +02:00
|
|
|
%feature("director") SearchMonitor::BeginFail;
|
2014-07-09 11:17:29 +00:00
|
|
|
%unignore SearchMonitor::EndFail;
|
2015-08-13 16:00:54 +02:00
|
|
|
%feature("director") SearchMonitor::EndFail;
|
2014-07-09 11:17:29 +00:00
|
|
|
%unignore SearchMonitor::BeginInitialPropagation;
|
2015-08-13 16:00:54 +02:00
|
|
|
%feature("director") SearchMonitor::BeginInitialPropagation;
|
2014-07-09 11:17:29 +00:00
|
|
|
%unignore SearchMonitor::EndInitialPropagation;
|
2015-08-13 16:00:54 +02:00
|
|
|
%feature("director") SearchMonitor::EndInitialPropagation;
|
2014-07-09 11:17:29 +00:00
|
|
|
%unignore SearchMonitor::AcceptSolution;
|
2015-08-13 16:00:54 +02:00
|
|
|
%feature("director") SearchMonitor::AcceptSolution;
|
2014-07-09 11:17:29 +00:00
|
|
|
%unignore SearchMonitor::AtSolution;
|
2015-08-13 16:00:54 +02:00
|
|
|
%feature("director") SearchMonitor::AtSolution;
|
2014-07-09 11:17:29 +00:00
|
|
|
%unignore SearchMonitor::NoMoreSolutions;
|
2015-08-13 16:00:54 +02:00
|
|
|
%feature("director") SearchMonitor::NoMoreSolutions;
|
2014-07-09 11:17:29 +00:00
|
|
|
%unignore SearchMonitor::LocalOptimum;
|
2015-08-13 16:00:54 +02:00
|
|
|
%feature("director") SearchMonitor::LocalOptimum;
|
2014-07-09 11:17:29 +00:00
|
|
|
%unignore SearchMonitor::AcceptDelta;
|
2015-08-13 16:00:54 +02:00
|
|
|
%feature("director") SearchMonitor::AcceptDelta;
|
2014-07-09 11:17:29 +00:00
|
|
|
%unignore SearchMonitor::AcceptNeighbor;
|
2015-08-13 16:00:54 +02:00
|
|
|
%feature("director") SearchMonitor::AcceptNeighbor;
|
2014-07-22 19:09:57 +00:00
|
|
|
%rename (solver) SearchMonitor::solver;
|
2015-01-13 10:52:12 +00:00
|
|
|
%feature("nodirector") SearchMonitor::solver;
|
2014-07-09 11:17:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
// Rev<>
|
|
|
|
|
%unignore Rev;
|
|
|
|
|
%unignore Rev::Rev;
|
|
|
|
|
%unignore Rev::Value;
|
|
|
|
|
%unignore Rev::SetValue;
|
|
|
|
|
|
|
|
|
|
// IntExpr
|
|
|
|
|
// Ignored:
|
|
|
|
|
// - IntExpr()
|
|
|
|
|
// - ~IntExpr()
|
|
|
|
|
// - Accept()
|
|
|
|
|
%unignore IntExpr;
|
|
|
|
|
%unignore IntExpr::Min;
|
|
|
|
|
%unignore IntExpr::Max;
|
|
|
|
|
%unignore IntExpr::Bound;
|
|
|
|
|
%unignore IntExpr::SetValue;
|
|
|
|
|
%unignore IntExpr::SetMin;
|
|
|
|
|
%unignore IntExpr::SetMax;
|
|
|
|
|
%unignore IntExpr::SetRange;
|
|
|
|
|
%unignore IntExpr::Var;
|
|
|
|
|
%unignore IntExpr::IsVar;
|
|
|
|
|
%unignore IntExpr::VarWithName;
|
|
|
|
|
%unignore IntExpr::WhenRange;
|
|
|
|
|
|
2014-07-24 18:27:32 +00:00
|
|
|
|
2014-07-09 11:17:29 +00:00
|
|
|
// IntVar
|
|
|
|
|
// Ignored:
|
|
|
|
|
// - IntVar()
|
|
|
|
|
// - ~IntVar()
|
|
|
|
|
// - VarType()
|
|
|
|
|
// - Accept()
|
|
|
|
|
// - IsEqual()
|
|
|
|
|
// - IsDifferent()
|
|
|
|
|
// - IsGreaterOrEqual()
|
|
|
|
|
// - IsLessOrEqual()
|
|
|
|
|
%unignore IntVar;
|
|
|
|
|
%unignore IntVar::Value;
|
|
|
|
|
%unignore IntVar::Size;
|
|
|
|
|
%unignore IntVar::Contains;
|
|
|
|
|
%unignore IntVar::RemoveValue;
|
|
|
|
|
%unignore IntVar::RemoveValues;
|
|
|
|
|
%unignore IntVar::RemoveInterval;
|
|
|
|
|
%unignore IntVar::SetValues;
|
|
|
|
|
%unignore IntVar::Var;
|
|
|
|
|
%unignore IntVar::IsVar;
|
|
|
|
|
%unignore IntVar::WhenBound;
|
|
|
|
|
%unignore IntVar::WhenDomain;
|
|
|
|
|
%rename (HoleIteratorAux) IntVar::MakeHoleIterator;
|
|
|
|
|
%feature("director") IntVar::MakeHoleIterator;
|
|
|
|
|
%rename (DomainIteratorAux) IntVar::MakeDomainIterator;
|
|
|
|
|
%feature("director") IntVar::MakeDomainIterator;
|
|
|
|
|
%unignore IntVar::OldMin;
|
|
|
|
|
%unignore IntVar::OldMax;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// SolutionCollector.
|
|
|
|
|
// Ignored:
|
|
|
|
|
// - SolutionCollector()
|
|
|
|
|
// - ~SolutionCollector()
|
|
|
|
|
// - EnterSearch()
|
|
|
|
|
%unignore SolutionCollector;
|
|
|
|
|
%unignore SolutionCollector::Value;
|
|
|
|
|
%unignore SolutionCollector::StartValue;
|
|
|
|
|
%unignore SolutionCollector::EndValue;
|
|
|
|
|
%unignore SolutionCollector::DurationValue;
|
|
|
|
|
%unignore SolutionCollector::PerformedValue;
|
|
|
|
|
%unignore SolutionCollector::ForwardSequence;
|
|
|
|
|
%unignore SolutionCollector::BackwardSequence;
|
|
|
|
|
%unignore SolutionCollector::Unperformed;
|
|
|
|
|
%rename (Solution) SolutionCollector::solution;
|
|
|
|
|
%rename (SolutionCount) SolutionCollector::solution_count;
|
|
|
|
|
%rename (ObjectiveValue) SolutionCollector::objective_value;
|
|
|
|
|
%rename (WallTime) SolutionCollector::wall_time;
|
|
|
|
|
%rename (Branches) SolutionCollector::branches;
|
|
|
|
|
%rename (Failures) SolutionCollector::failures;
|
|
|
|
|
%unignore SolutionCollector::Add;
|
|
|
|
|
%unignore SolutionCollector::AddObjective;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// OptimizeVar.
|
|
|
|
|
// Ignored:
|
|
|
|
|
// - OptimizeVar()
|
|
|
|
|
// - ~OptimizeVat()
|
|
|
|
|
// - EnterSearch()
|
|
|
|
|
// - BeginNextDecision()
|
|
|
|
|
// - RefuteDecision()
|
|
|
|
|
// - AtSolution()
|
|
|
|
|
// - AcceptSolution()
|
|
|
|
|
// - Print()
|
|
|
|
|
// - DebugString()
|
|
|
|
|
// - Accept()
|
|
|
|
|
// - ApplyBound()
|
|
|
|
|
%unignore OptimizeVar;
|
|
|
|
|
%rename (Best) OptimizeVar::best;
|
|
|
|
|
%unignore OptimizeVar::Var;
|
|
|
|
|
|
|
|
|
|
// SearchLimit.
|
|
|
|
|
// Ignored:
|
|
|
|
|
// - SearchLimit()
|
|
|
|
|
// - ~SearchLimit()
|
|
|
|
|
// - crossed()
|
|
|
|
|
// - Check()
|
|
|
|
|
// - Init()
|
|
|
|
|
// - Copy()
|
|
|
|
|
// - MakeClone()
|
|
|
|
|
// - EnterSearch()
|
|
|
|
|
// - BeginNextDecision()
|
|
|
|
|
// - PeriodicCheck()
|
|
|
|
|
// - RefuteDecision()
|
|
|
|
|
// - DebugString()
|
|
|
|
|
%unignore SearchLimit;
|
|
|
|
|
%rename (Crossed) SearchLimit::crossed;
|
|
|
|
|
%unignore SearchLimit::SearchLimit;
|
|
|
|
|
%unignore SearchLimit::~SearchLimit;
|
|
|
|
|
%unignore SearchLimit::Check;
|
|
|
|
|
%unignore SearchLimit::Init;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// IntervalVar
|
|
|
|
|
// Ignored:
|
|
|
|
|
// - kMinValidValue
|
|
|
|
|
// - kMaxValidValue
|
|
|
|
|
// - IntervalVar()
|
|
|
|
|
// - ~IntervalVar()
|
|
|
|
|
// - Accept()
|
|
|
|
|
%unignore IntervalVar;
|
|
|
|
|
%unignore IntervalVar::StartExpr;
|
|
|
|
|
%unignore IntervalVar::DurationExpr;
|
|
|
|
|
%unignore IntervalVar::EndExpr;
|
|
|
|
|
%unignore IntervalVar::SafeStartExpr;
|
|
|
|
|
%unignore IntervalVar::SafeDurationExpr;
|
|
|
|
|
%unignore IntervalVar::SafeEndExpr;
|
|
|
|
|
%unignore IntervalVar::PerformedExpr;
|
|
|
|
|
%unignore IntervalVar::StartMin;
|
|
|
|
|
%unignore IntervalVar::StartMax;
|
|
|
|
|
%unignore IntervalVar::SetStartMin;
|
|
|
|
|
%unignore IntervalVar::SetStartMax;
|
|
|
|
|
%unignore IntervalVar::SetStartRange;
|
|
|
|
|
%unignore IntervalVar::DurationMin;
|
|
|
|
|
%unignore IntervalVar::DurationMax;
|
|
|
|
|
%unignore IntervalVar::SetDurationMin;
|
|
|
|
|
%unignore IntervalVar::SetDurationMax;
|
|
|
|
|
%unignore IntervalVar::SetDurationRange;
|
|
|
|
|
%unignore IntervalVar::EndMin;
|
|
|
|
|
%unignore IntervalVar::EndMax;
|
|
|
|
|
%unignore IntervalVar::SetEndMin;
|
|
|
|
|
%unignore IntervalVar::SetEndMax;
|
|
|
|
|
%unignore IntervalVar::SetEndRange;
|
|
|
|
|
%unignore IntervalVar::MustBePerformed;
|
|
|
|
|
%unignore IntervalVar::MayBePerformed;
|
|
|
|
|
%unignore IntervalVar::CannotBePerformed;
|
|
|
|
|
%unignore IntervalVar::SetPerformed;
|
|
|
|
|
%unignore IntervalVar::IsPerformedBound;
|
|
|
|
|
%unignore IntervalVar::OldStartMin;
|
|
|
|
|
%unignore IntervalVar::OldStartMax;
|
|
|
|
|
%unignore IntervalVar::OldDurationMin;
|
|
|
|
|
%unignore IntervalVar::OldDurationMax;
|
|
|
|
|
%unignore IntervalVar::OldEndMin;
|
|
|
|
|
%unignore IntervalVar::OldEndMax;
|
|
|
|
|
%unignore IntervalVar::WhenStartRange;
|
|
|
|
|
%unignore IntervalVar::WhenStartBound;
|
|
|
|
|
%unignore IntervalVar::WhenDurationRange;
|
|
|
|
|
%unignore IntervalVar::WhenDurationBound;
|
|
|
|
|
%unignore IntervalVar::WhenEndRange;
|
|
|
|
|
%unignore IntervalVar::WhenEndBound;
|
|
|
|
|
%unignore IntervalVar::WasPerformedBound;
|
|
|
|
|
%unignore IntervalVar::WhenPerformedBound;
|
|
|
|
|
%unignore IntervalVar::WhenAnything;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// SequenceVar.
|
|
|
|
|
// Ignored:
|
|
|
|
|
// - SequenceVar()
|
|
|
|
|
// - ~SequenceVar()
|
|
|
|
|
// - DebugString()
|
|
|
|
|
// - DurationRange()
|
|
|
|
|
// - HorizonRange()
|
|
|
|
|
// - ActiveHorizonRange()
|
|
|
|
|
// - ComputeStatistics()
|
|
|
|
|
// - ComputePossibleFirstsAndLasts()
|
|
|
|
|
// - RankSequence()
|
|
|
|
|
// - FillSequence()
|
|
|
|
|
// - Accept()
|
|
|
|
|
%unignore SequenceVar;
|
|
|
|
|
%unignore SequenceVar::RankFirst;
|
|
|
|
|
%unignore SequenceVar::RankNotFirst;
|
|
|
|
|
%unignore SequenceVar::RankLast;
|
|
|
|
|
%unignore SequenceVar::RankNotLast;
|
|
|
|
|
%unignore SequenceVar::Interval;
|
|
|
|
|
%unignore SequenceVar::Next;
|
|
|
|
|
%rename (Size) SequenceVar::size;
|
|
|
|
|
|
|
|
|
|
// Assignment
|
|
|
|
|
// Ignored:
|
|
|
|
|
// - Assignment()
|
|
|
|
|
// - ~Assignment()
|
|
|
|
|
// - FastAdd()
|
|
|
|
|
// - DebugString()
|
|
|
|
|
// - Contains()
|
|
|
|
|
// - Copy()
|
|
|
|
|
// - ==()
|
|
|
|
|
// - !=()
|
|
|
|
|
%unignore Assignment;
|
|
|
|
|
%unignore Assignment::Clear;
|
|
|
|
|
%unignore Assignment::Size;
|
|
|
|
|
%unignore Assignment::Empty;
|
|
|
|
|
%unignore Assignment::NumIntVars;
|
|
|
|
|
%unignore Assignment::NumIntervalVars;
|
|
|
|
|
%unignore Assignment::NumSequenceVars;
|
|
|
|
|
%unignore Assignment::Add;
|
|
|
|
|
%unignore Assignment::Store;
|
|
|
|
|
%unignore Assignment::Restore;
|
|
|
|
|
%unignore Assignment::Load;
|
|
|
|
|
%unignore Assignment::Save;
|
|
|
|
|
|
|
|
|
|
// Assignment: activate/deactivate.
|
|
|
|
|
%unignore Assignment::Activate;
|
|
|
|
|
%unignore Assignment::Deactivate;
|
|
|
|
|
%unignore Assignment::Activated;
|
|
|
|
|
%unignore Assignment::ObjectiveActivate;
|
|
|
|
|
%unignore Assignment::ObjectiveDeactivate;
|
|
|
|
|
%unignore Assignment::ObjectiveActivated;
|
|
|
|
|
|
|
|
|
|
// Assignment: Objective API.
|
|
|
|
|
%unignore Assignment::HasObjective;
|
|
|
|
|
%unignore Assignment::Objective;
|
|
|
|
|
%unignore Assignment::AddObjective;
|
|
|
|
|
%unignore Assignment::ObjectiveMin;
|
|
|
|
|
%unignore Assignment::ObjectiveMax;
|
|
|
|
|
%unignore Assignment::ObjectiveValue;
|
|
|
|
|
%unignore Assignment::ObjectiveBound;
|
|
|
|
|
%unignore Assignment::SetObjectiveMin;
|
|
|
|
|
%unignore Assignment::SetObjectiveMax;
|
|
|
|
|
%unignore Assignment::SetObjectiveValue;
|
|
|
|
|
%unignore Assignment::SetObjectiveRange;
|
|
|
|
|
|
|
|
|
|
// Assignment: IntVar API.
|
|
|
|
|
%unignore Assignment::Min;
|
|
|
|
|
%unignore Assignment::Max;
|
|
|
|
|
%unignore Assignment::Value;
|
|
|
|
|
%unignore Assignment::Bound;
|
|
|
|
|
%unignore Assignment::SetMin;
|
|
|
|
|
%unignore Assignment::SetMax;
|
|
|
|
|
%unignore Assignment::SetRange;
|
|
|
|
|
|
|
|
|
|
// Assignment: IntervalVar API.
|
|
|
|
|
%unignore Assignment::SetValue;
|
|
|
|
|
%unignore Assignment::StartMin;
|
|
|
|
|
%unignore Assignment::StartMax;
|
|
|
|
|
%unignore Assignment::StartValue;
|
|
|
|
|
%unignore Assignment::DurationMin;
|
|
|
|
|
%unignore Assignment::DurationMax;
|
|
|
|
|
%unignore Assignment::DurationValue;
|
|
|
|
|
%unignore Assignment::EndMin;
|
|
|
|
|
%unignore Assignment::EndMax;
|
|
|
|
|
%unignore Assignment::EndValue;
|
|
|
|
|
%unignore Assignment::PerformedMin;
|
|
|
|
|
%unignore Assignment::PerformedMax;
|
|
|
|
|
%unignore Assignment::PerformedValue;
|
|
|
|
|
%unignore Assignment::SetStartMin;
|
|
|
|
|
%unignore Assignment::SetStartMax;
|
|
|
|
|
%unignore Assignment::SetStartRange;
|
|
|
|
|
%unignore Assignment::SetStartValue;
|
|
|
|
|
%unignore Assignment::SetDurationMin;
|
|
|
|
|
%unignore Assignment::SetDurationMax;
|
|
|
|
|
%unignore Assignment::SetDurationRange;
|
|
|
|
|
%unignore Assignment::SetDurationValue;
|
|
|
|
|
%unignore Assignment::SetEndMin;
|
|
|
|
|
%unignore Assignment::SetEndMax;
|
|
|
|
|
%unignore Assignment::SetEndValue;
|
|
|
|
|
%unignore Assignment::SetEndRange;
|
|
|
|
|
%unignore Assignment::SetPerformedMin;
|
|
|
|
|
%unignore Assignment::SetPerformedMax;
|
|
|
|
|
%unignore Assignment::SetPerformedRange;
|
|
|
|
|
%unignore Assignment::SetPerformedValue;
|
|
|
|
|
|
|
|
|
|
// Assignment: SequenceVar API.
|
|
|
|
|
%unignore Assignment::ForwardSequence;
|
|
|
|
|
%unignore Assignment::BackwardSequence;
|
|
|
|
|
%unignore Assignment::Unperformed;
|
|
|
|
|
%unignore Assignment::SetForwardSequence;
|
|
|
|
|
%unignore Assignment::SetBackwardSequence;
|
|
|
|
|
%unignore Assignment::SetUnperformed;
|
|
|
|
|
%unignore Assignment::SetSequence;
|
|
|
|
|
|
|
|
|
|
// Assignment: underlying containers.
|
|
|
|
|
%unignore Assignment::IntVarContainer;
|
|
|
|
|
%unignore Assignment::MutableIntVarContainer;
|
|
|
|
|
%unignore Assignment::IntervalVarContainer;
|
|
|
|
|
%unignore Assignment::MutableIntervalVarContainer;
|
|
|
|
|
%unignore Assignment::SequenceVarContainer;
|
|
|
|
|
%unignore Assignment::MutableSequenceVarContainer;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// DisjunctiveConstraint
|
|
|
|
|
// Ignored:
|
|
|
|
|
// - DisjunctiveConstraint()
|
|
|
|
|
// - ~DisjunctiveConstraint()
|
|
|
|
|
%unignore DisjunctiveConstraint;
|
|
|
|
|
%rename (SequenceVar) DisjunctiveConstraint::MakeSequenceVar;
|
|
|
|
|
%unignore DisjunctiveConstraint::SetTransitionTime;
|
|
|
|
|
%unignore DisjunctiveConstraint::TransitionTime;
|
|
|
|
|
|
|
|
|
|
// Pack (Constraint)
|
|
|
|
|
// Ignored:
|
|
|
|
|
// - typedefs:
|
|
|
|
|
// - ItemUsageEvaluator
|
|
|
|
|
// - ItemUsagePerBinEvaluator
|
|
|
|
|
// - Pack()
|
|
|
|
|
// - ~Pack()
|
|
|
|
|
// - Post()
|
|
|
|
|
// - ClearAll()
|
|
|
|
|
// - PropagateDelayed()
|
|
|
|
|
// - InitialPropagate()
|
|
|
|
|
// - Propagate()
|
|
|
|
|
// - OneDomain()
|
|
|
|
|
// - DebugString()
|
|
|
|
|
// - IsUndecided()
|
|
|
|
|
// - SetImpossible()
|
|
|
|
|
// - Assign()
|
|
|
|
|
// - IsAssignedStatusKnown()
|
|
|
|
|
// - IsPossible()
|
|
|
|
|
// - AssignVar()
|
|
|
|
|
// - SetAssigned()
|
|
|
|
|
// - SetUnassigned()
|
|
|
|
|
// - RemoveAllPossibleFromBin()
|
|
|
|
|
// - AssignAllPossibleToBin()
|
|
|
|
|
// - AssignFirstPossibleToBin()
|
|
|
|
|
// - AssignAllRemainingItems()
|
|
|
|
|
// - UnassignAllRemainingItems()
|
|
|
|
|
// - Accept()
|
|
|
|
|
%unignore Pack;
|
|
|
|
|
%unignore Pack::AddWeightedSumLessOrEqualConstantDimension;
|
|
|
|
|
%unignore Pack::AddWeightedSumLessOrEqualConstantDimension;
|
|
|
|
|
%unignore Pack::AddWeightedSumLessOrEqualConstantDimension;
|
|
|
|
|
%unignore Pack::AddWeightedSumEqualVarDimension;
|
|
|
|
|
%unignore Pack::AddWeightedSumEqualVarDimension;
|
|
|
|
|
%unignore Pack::AddSumVariableWeightsLessOrEqualConstantDimension;
|
|
|
|
|
%unignore Pack::AddWeightedSumOfAssignedDimension;
|
|
|
|
|
%unignore Pack::AddCountUsedBinDimension;
|
|
|
|
|
%unignore Pack::AddCountAssignedItemsDimension;
|
|
|
|
|
|
|
|
|
|
// LocalSearchPhaseParameters
|
|
|
|
|
%unignore LocalSearchPhaseParameters;
|
|
|
|
|
|
|
|
|
|
// Demon
|
|
|
|
|
// Ignored:
|
|
|
|
|
// - priority()
|
|
|
|
|
// - DebugString()
|
|
|
|
|
%feature("director") Demon;
|
|
|
|
|
%unignore Demon;
|
|
|
|
|
%unignore Demon::Demon;
|
|
|
|
|
%unignore Demon::~Demon;
|
|
|
|
|
%rename (RunWrapper) Demon::Run;
|
|
|
|
|
%rename (Inhibit) Demon::inhibit;
|
|
|
|
|
%rename (Desinhibit) Demon::desinhibit;
|
|
|
|
|
|
|
|
|
|
// AssignmentElement
|
|
|
|
|
// Ignored:
|
|
|
|
|
// - AssignmentElement()
|
|
|
|
|
%unignore AssignmentElement;
|
|
|
|
|
%unignore AssignmentElement::Activate;
|
|
|
|
|
%unignore AssignmentElement::Deactivate;
|
|
|
|
|
%unignore AssignmentElement::Activated;
|
|
|
|
|
|
|
|
|
|
// IntVarElement
|
|
|
|
|
// Ignored:
|
|
|
|
|
// - IntVarElement()
|
|
|
|
|
// - ~IntVarElement()
|
|
|
|
|
// - Reset()
|
|
|
|
|
// - Clone()
|
|
|
|
|
// - Copy()
|
|
|
|
|
// - Store()
|
|
|
|
|
// - Restore()
|
|
|
|
|
// - LoadFromProto()
|
|
|
|
|
// - WriteToProto()
|
|
|
|
|
// - DebugString()
|
|
|
|
|
// - operator==()
|
|
|
|
|
// - operator!=()
|
|
|
|
|
%unignore IntVarElement;
|
|
|
|
|
%unignore IntVarElement::Min;
|
|
|
|
|
%unignore IntVarElement::SetMin;
|
|
|
|
|
%unignore IntVarElement::Max;
|
|
|
|
|
%unignore IntVarElement::SetMax;
|
|
|
|
|
%unignore IntVarElement::Value;
|
|
|
|
|
%unignore IntVarElement::Bound;
|
|
|
|
|
%unignore IntVarElement::SetRange;
|
|
|
|
|
%unignore IntVarElement::SetValue;
|
|
|
|
|
%unignore IntVarElement::Var;
|
|
|
|
|
|
|
|
|
|
// IntervalVarElement
|
|
|
|
|
// Ignored:
|
|
|
|
|
// - IntervalVarElement()
|
|
|
|
|
// - ~IntervalVarElement()
|
|
|
|
|
// - Reset()
|
|
|
|
|
// - Clone()
|
|
|
|
|
// - Copy()
|
|
|
|
|
// - Var()
|
|
|
|
|
// - Store()
|
|
|
|
|
// - Restore()
|
|
|
|
|
// - LoadFromProto()
|
|
|
|
|
// - WriteToProto()
|
|
|
|
|
// - DebugString()
|
|
|
|
|
// - operator==()
|
|
|
|
|
// - operator!=()
|
|
|
|
|
%unignore IntervalVarElement;
|
|
|
|
|
%unignore IntervalVarElement::StartMin;
|
|
|
|
|
%unignore IntervalVarElement::StartMax;
|
|
|
|
|
%unignore IntervalVarElement::StartValue;
|
|
|
|
|
%unignore IntervalVarElement::DurationMin;
|
|
|
|
|
%unignore IntervalVarElement::DurationMax;
|
|
|
|
|
%unignore IntervalVarElement::DurationValue;
|
|
|
|
|
%unignore IntervalVarElement::EndMin;
|
|
|
|
|
%unignore IntervalVarElement::EndMax;
|
|
|
|
|
%unignore IntervalVarElement::EndValue;
|
|
|
|
|
%unignore IntervalVarElement::PerformedMin;
|
|
|
|
|
%unignore IntervalVarElement::PerformedMax;
|
|
|
|
|
%unignore IntervalVarElement::PerformedValue;
|
|
|
|
|
%unignore IntervalVarElement::SetStartMin;
|
|
|
|
|
%unignore IntervalVarElement::SetStartMax;
|
|
|
|
|
%unignore IntervalVarElement::SetStartRange;
|
|
|
|
|
%unignore IntervalVarElement::SetStartValue;
|
|
|
|
|
%unignore IntervalVarElement::SetDurationMin;
|
|
|
|
|
%unignore IntervalVarElement::SetDurationMax;
|
|
|
|
|
%unignore IntervalVarElement::SetDurationRange;
|
|
|
|
|
%unignore IntervalVarElement::SetDurationValue;
|
|
|
|
|
%unignore IntervalVarElement::SetEndMin;
|
|
|
|
|
%unignore IntervalVarElement::SetEndMax;
|
|
|
|
|
%unignore IntervalVarElement::SetEndRange;
|
|
|
|
|
%unignore IntervalVarElement::SetEndValue;
|
|
|
|
|
%unignore IntervalVarElement::SetPerformedMin;
|
|
|
|
|
%unignore IntervalVarElement::SetPerformedMax;
|
|
|
|
|
%unignore IntervalVarElement::SetPerformedRange;
|
|
|
|
|
%unignore IntervalVarElement::SetPerformedValue;
|
|
|
|
|
|
|
|
|
|
// SequenceVarElement
|
|
|
|
|
// Ignored:
|
|
|
|
|
// - SequenceVarElement()
|
|
|
|
|
// - ~SequenceVarElement()
|
|
|
|
|
// - Reset()
|
|
|
|
|
// - Clone()
|
|
|
|
|
// - Copy()
|
|
|
|
|
// - Var()
|
|
|
|
|
// - Store()
|
|
|
|
|
// - Restore()
|
|
|
|
|
// - LoadFromProto()
|
|
|
|
|
// - WriteToProto()
|
|
|
|
|
// - DebugString()
|
|
|
|
|
// - operator==()
|
|
|
|
|
// - operator!=()
|
|
|
|
|
%unignore SequenceVarElement;
|
|
|
|
|
%unignore SequenceVarElement::ForwardSequence;
|
|
|
|
|
%unignore SequenceVarElement::BackwardSequence;
|
|
|
|
|
%unignore SequenceVarElement::Unperformed;
|
|
|
|
|
%unignore SequenceVarElement::SetSequence;
|
|
|
|
|
%unignore SequenceVarElement::SetForwardSequence;
|
|
|
|
|
%unignore SequenceVarElement::SetBackwardSequence;
|
|
|
|
|
%unignore SequenceVarElement::SetUnperformed;
|
|
|
|
|
|
|
|
|
|
// AssignmentContainer<>
|
|
|
|
|
// Ignored:
|
|
|
|
|
// - AssignmentContainer()
|
|
|
|
|
// - Add()
|
|
|
|
|
// - FastAdd()
|
|
|
|
|
// - AddAtPosition()
|
|
|
|
|
// - Clear()
|
|
|
|
|
// - Resize()
|
|
|
|
|
// - Empty()
|
|
|
|
|
// - Copy()
|
|
|
|
|
// - elements()
|
|
|
|
|
// - All Element() method taking (const V* const var)
|
|
|
|
|
// - operator==()
|
|
|
|
|
// - operator!=()
|
|
|
|
|
%unignore AssignmentContainer;
|
|
|
|
|
%unignore AssignmentContainer::Contains;
|
|
|
|
|
%rename (Element) AssignmentContainer::MutableElement(int);
|
|
|
|
|
%unignore AssignmentContainer::Size;
|
|
|
|
|
%unignore AssignmentContainer::Store;
|
|
|
|
|
%unignore AssignmentContainer::Restore;
|
|
|
|
|
|
|
|
|
|
// IntVarIterator
|
|
|
|
|
// Ignored:
|
|
|
|
|
// - ~IntVarIterator()
|
|
|
|
|
// - DebugString()
|
|
|
|
|
%unignore IntVarIterator;
|
|
|
|
|
%unignore IntVarIterator::Init;
|
|
|
|
|
%unignore IntVarIterator::Value;
|
|
|
|
|
%unignore IntVarIterator::Next;
|
|
|
|
|
%unignore IntVarIterator::Ok;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace operations_research
|
|
|
|
|
|
|
|
|
|
%include "constraint_solver/constraint_solver.h"
|
2010-09-15 12:42:33 +00:00
|
|
|
|
|
|
|
|
// Define templates instantiation after wrapping.
|
|
|
|
|
namespace operations_research {
|
2014-07-09 11:17:29 +00:00
|
|
|
%rename (RevInteger) Rev<int64>;
|
|
|
|
|
%rename (RevInteger) Rev<int64>::Rev;
|
|
|
|
|
%unignore Rev<int64>::SetValue;
|
2016-01-05 18:38:47 +01:00
|
|
|
%unignore Rev<int64>::Value;
|
2010-09-15 12:42:33 +00:00
|
|
|
%template(RevInteger) Rev<int64>;
|
2014-07-09 11:17:29 +00:00
|
|
|
|
2016-01-05 18:38:47 +01:00
|
|
|
%rename (NumericalRevInteger) NumericalRev<int64>;
|
|
|
|
|
%rename (NumericalRevInteger) NumericalRev<int64>::NumericalRev;
|
|
|
|
|
%unignore NumericalRev<int64>::Add;
|
|
|
|
|
%unignore NumericalRev<int64>::Decr;
|
|
|
|
|
%unignore NumericalRev<int64>::Incr;
|
|
|
|
|
%unignore NumericalRev<int64>::SetValue;
|
|
|
|
|
%unignore NumericalRev<int64>::Value;
|
|
|
|
|
%template(NumericalRevInteger) NumericalRev<int64>;
|
|
|
|
|
|
2014-07-09 11:17:29 +00:00
|
|
|
%rename (RevBool) Rev<bool>;
|
|
|
|
|
%rename (RevBool) Rev<bool>::Rev;
|
|
|
|
|
%unignore Rev<bool>::Value;
|
|
|
|
|
%unignore Rev<bool>::SetValue;
|
2010-10-15 13:22:21 +00:00
|
|
|
%template(RevBool) Rev<bool>;
|
2014-05-22 17:37:21 +00:00
|
|
|
|
2014-07-09 11:17:29 +00:00
|
|
|
%rename (IntContainer) AssignmentContainer<IntVar, IntVarElement>;
|
|
|
|
|
%rename (Element)
|
|
|
|
|
AssignmentContainer<IntVar, IntVarElement>::MutableElement(int);
|
|
|
|
|
%unignore AssignmentContainer<IntVar, IntVarElement>::Size;
|
|
|
|
|
%template (IntContainer) AssignmentContainer<IntVar, IntVarElement>;
|
|
|
|
|
%rename (IntervalContainer)
|
|
|
|
|
AssignmentContainer<IntervalVar, IntervalVarElement>;
|
|
|
|
|
%template (IntervalContainer)
|
|
|
|
|
AssignmentContainer<IntervalVar, IntervalVarElement>;
|
|
|
|
|
%rename (SequenceContainer)
|
|
|
|
|
AssignmentContainer<SequenceVar, SequenceVarElement>;
|
|
|
|
|
%template (SequenceContainer)
|
|
|
|
|
AssignmentContainer<SequenceVar, SequenceVarElement>;
|
|
|
|
|
|
|
|
|
|
} // namespace operations_research
|
|
|
|
|
|
|
|
|
|
// ================= constraint_solver.i API =====================
|
|
|
|
|
|
|
|
|
|
namespace operations_research {
|
|
|
|
|
|
|
|
|
|
// Ignored top-level classes, enums and methods:
|
|
|
|
|
// - BaseIntExpr
|
|
|
|
|
// - VarTypes (enum)
|
|
|
|
|
// - IntVarLocalSearchHandler
|
|
|
|
|
// - SequenceVarLocalSearchHandler
|
|
|
|
|
// - ChangeValue
|
|
|
|
|
// - PathOperator
|
|
|
|
|
// - MakeLocalSearchOperator()
|
|
|
|
|
// - PropagationMonitor
|
|
|
|
|
// - SymmetryBreaker
|
|
|
|
|
// - SearchLog
|
|
|
|
|
// - ModelCache
|
|
|
|
|
//
|
|
|
|
|
// - RevGrowingArray<>
|
|
|
|
|
// - RevIntSet<>
|
|
|
|
|
// - RevPartialSequence
|
|
|
|
|
// - IsArrayConstant<>()
|
|
|
|
|
// - IsArrayBoolean<>()
|
|
|
|
|
// - AreAllOnes<>()
|
|
|
|
|
// - AreAllNull<>()
|
|
|
|
|
// - AreAllGreaterOrEqual<>()
|
|
|
|
|
// - AreAllPositive<>()
|
|
|
|
|
// - AreAllStrictlyPositive<>()
|
|
|
|
|
// - IsIncreasingContiguous<>()
|
|
|
|
|
// - IsIncreasing<>()
|
|
|
|
|
// - IsArrayInRange<>()
|
|
|
|
|
// - AreAllBound()
|
|
|
|
|
// - AreAllBooleans()
|
|
|
|
|
// - AreAllBoundOrNull<>()
|
|
|
|
|
// - AreAllBoundTo()
|
|
|
|
|
// - MaxVarArray()
|
|
|
|
|
// - MinVarArray()
|
|
|
|
|
// - FillValues()
|
|
|
|
|
// - PosIntDivUp()
|
|
|
|
|
// - PosIntDivDown()
|
|
|
|
|
// - AreAllBoundTo()
|
|
|
|
|
// - MaxVarArray()
|
|
|
|
|
// - MinVarArray()
|
|
|
|
|
// - FillValues()
|
|
|
|
|
// - PosIntDivUp()
|
|
|
|
|
// - PosIntDivDown()
|
|
|
|
|
// - ToInt64Vector()
|
|
|
|
|
|
|
|
|
|
// LocalSearchOperator
|
|
|
|
|
// Ignored:
|
|
|
|
|
// - LocalSearchOperator()
|
|
|
|
|
// - ~LocalSearchOperator()
|
2015-11-20 18:43:11 +01:00
|
|
|
%feature("director") LocalSearchOperator;
|
2014-07-09 11:17:29 +00:00
|
|
|
%unignore LocalSearchOperator;
|
|
|
|
|
%rename (NextNeighbor) LocalSearchOperator::MakeNextNeighbor;
|
|
|
|
|
%unignore LocalSearchOperator::Start;
|
|
|
|
|
%feature("director") LocalSearchOperator::MakeNextNeighbor;
|
|
|
|
|
%feature("director") LocalSearchOperator::Start;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// VarLocalSearchOperator<>
|
|
|
|
|
// Ignored:
|
|
|
|
|
// - VarLocalSearchOperator()
|
|
|
|
|
// - ~VarLocalSearchOperator()
|
|
|
|
|
// - Start()
|
|
|
|
|
// - Var()
|
|
|
|
|
// - SkipUnchanged()
|
|
|
|
|
// - Activated()
|
|
|
|
|
// - Activate()
|
|
|
|
|
// - Deactivate()
|
|
|
|
|
// - ApplyChanges()
|
|
|
|
|
// - RevertChanges()
|
|
|
|
|
// - AddVars()
|
|
|
|
|
%unignore VarLocalSearchOperator;
|
|
|
|
|
%unignore VarLocalSearchOperator::Size;
|
|
|
|
|
%unignore VarLocalSearchOperator::Value;
|
|
|
|
|
%unignore VarLocalSearchOperator::IsIncremental;
|
|
|
|
|
%feature("director") VarLocalSearchOperator::IsIncremental;
|
|
|
|
|
%unignore VarLocalSearchOperator::IsIncremental;
|
|
|
|
|
%unignore VarLocalSearchOperator::OnStart;
|
|
|
|
|
%feature("director") VarLocalSearchOperator::OnStart;
|
|
|
|
|
%unignore VarLocalSearchOperator::OnStart;
|
|
|
|
|
%unignore VarLocalSearchOperator::OldValue;
|
|
|
|
|
%unignore VarLocalSearchOperator::SetValue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// IntVarLocalSearchOperator
|
|
|
|
|
// Ignored:
|
|
|
|
|
// - MakeNextNeighbor()
|
|
|
|
|
%unignore IntVarLocalSearchOperator;
|
|
|
|
|
%feature("director") IntVarLocalSearchOperator;
|
|
|
|
|
%unignore IntVarLocalSearchOperator::IntVarLocalSearchOperator;
|
|
|
|
|
%unignore IntVarLocalSearchOperator::~IntVarLocalSearchOperator;
|
|
|
|
|
%unignore IntVarLocalSearchOperator::Size;
|
|
|
|
|
%feature("director") IntVarLocalSearchOperator::MakeOneNeighbor;
|
|
|
|
|
%rename (OneNeighbor) IntVarLocalSearchOperator::MakeOneNeighbor;
|
|
|
|
|
|
|
|
|
|
|
2015-11-20 11:32:37 +01:00
|
|
|
// BaseLns.
|
2015-11-20 18:43:11 +01:00
|
|
|
%feature("director") BaseLns;
|
2015-11-20 11:32:37 +01:00
|
|
|
%unignore BaseLns::BaseLns;
|
2015-11-20 18:43:11 +01:00
|
|
|
%unignore BaseLns;
|
2015-11-20 11:32:37 +01:00
|
|
|
%unignore BaseLns::~BaseLns;
|
|
|
|
|
%unignore BaseLns::InitFragments;
|
|
|
|
|
%unignore BaseLns::NextFragment;
|
2015-11-20 18:43:11 +01:00
|
|
|
%feature ("nodirector") BaseLns::OnStart;
|
|
|
|
|
%feature ("nodirector") BaseLns::SkipUnchanged;
|
|
|
|
|
%feature ("nodirector") BaseLns::MakeOneNeighbor;
|
|
|
|
|
%unignore BaseLns::IsIncremental;
|
2015-11-20 11:32:37 +01:00
|
|
|
%unignore BaseLns::AppendToFragment;
|
|
|
|
|
%unignore BaseLns::FragmentSize;
|
2014-07-09 11:17:29 +00:00
|
|
|
|
|
|
|
|
// ChangeValue
|
|
|
|
|
%unignore ChangeValue;
|
2015-11-20 18:43:11 +01:00
|
|
|
%feature ("director") ChangeValue;
|
2014-07-09 11:17:29 +00:00
|
|
|
%unignore ChangeValue::ChangeValue;
|
|
|
|
|
%unignore ChangeValue::~ChangeValue;
|
|
|
|
|
%unignore ChangeValue::ModifyValue;
|
|
|
|
|
|
|
|
|
|
// SequenceVarLocalSearchOperator
|
|
|
|
|
// Ignored:
|
|
|
|
|
// - SequenceVarLocalSearchOperator()
|
|
|
|
|
// - ~SequenceVarLocalSearchOperator()
|
|
|
|
|
// - Sequence()
|
|
|
|
|
// - OldSequence()
|
|
|
|
|
// - SetForwardSequence()
|
|
|
|
|
// - SetBackwardSequence()
|
|
|
|
|
%unignore SequenceVarLocalSearchOperator;
|
|
|
|
|
%unignore SequenceVarLocalSearchOperator::Start;
|
|
|
|
|
|
|
|
|
|
// PathOperator
|
|
|
|
|
// Ignored:
|
|
|
|
|
// - PathOperator()
|
|
|
|
|
// - ~PathOperator()
|
|
|
|
|
// - SkipUnchanged()
|
|
|
|
|
// - Next()
|
|
|
|
|
// - Path()
|
|
|
|
|
// - number_of_nexts()
|
|
|
|
|
%unignore PathOperator;
|
|
|
|
|
%rename (Neighbor) PathOperator::MakeNeighbor;
|
|
|
|
|
%feature("director") PathOperator::MakeNeighbor;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// LocalSearchFilter
|
|
|
|
|
%unignore LocalSearchFilter;
|
|
|
|
|
%unignore LocalSearchFilter::Accept;
|
|
|
|
|
%unignore LocalSearchFilter::Synchronize;
|
|
|
|
|
%unignore LocalSearchFilter::IsIncremental;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// IntVarLocalSearchFilter
|
|
|
|
|
// Ignored:
|
|
|
|
|
// - Synchronize()
|
|
|
|
|
// - FindIndex()
|
|
|
|
|
// - AddVars()
|
|
|
|
|
// - Var()
|
|
|
|
|
// - IsVarSynced()
|
|
|
|
|
%feature("director") IntVarLocalSearchFilter;
|
|
|
|
|
%feature("nodirector") IntVarLocalSearchFilter::Start; // Inherited.
|
|
|
|
|
%unignore IntVarLocalSearchFilter;
|
|
|
|
|
%unignore IntVarLocalSearchFilter::IntVarLocalSearchFilter;
|
|
|
|
|
%unignore IntVarLocalSearchFilter::~IntVarLocalSearchFilter;
|
|
|
|
|
%unignore IntVarLocalSearchFilter::Value;
|
|
|
|
|
%unignore IntVarLocalSearchFilter::Size;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// BooleanVar
|
|
|
|
|
// Ignored:
|
|
|
|
|
// - kUnboundBooleanVarValue
|
|
|
|
|
// - BooleanVar()
|
|
|
|
|
// - ~BooleanVar()
|
|
|
|
|
// - SetMin()
|
|
|
|
|
// - SetMax()
|
|
|
|
|
// - SetRange()
|
|
|
|
|
// - Bound()
|
|
|
|
|
// - RemoveValue()
|
|
|
|
|
// - RemoveInterval()
|
|
|
|
|
// - WhenBound()
|
|
|
|
|
// - WhenRange()
|
|
|
|
|
// - WhenDomain()
|
|
|
|
|
// - Size()
|
|
|
|
|
// - MakeHoleIterator()
|
|
|
|
|
// - MakeDomainIterator()
|
|
|
|
|
// - DebugString()
|
|
|
|
|
// - VarType()
|
|
|
|
|
// - IsEqual()
|
|
|
|
|
// - IsDifferent()
|
|
|
|
|
// - IsGreaterOrEqual()
|
|
|
|
|
// - IsLessOrEqual()
|
|
|
|
|
// - RestoreValue()
|
|
|
|
|
// - BaseName()
|
|
|
|
|
// - RawValue()
|
|
|
|
|
%unignore BooleanVar;
|
|
|
|
|
%unignore BooleanVar::Value;
|
|
|
|
|
%unignore BooleanVar::Min;
|
|
|
|
|
%unignore BooleanVar::Max;
|
|
|
|
|
%unignore BooleanVar::Contains;
|
|
|
|
|
|
|
|
|
|
} // namespace operations_research
|
|
|
|
|
|
|
|
|
|
%include "constraint_solver/constraint_solveri.h"
|
|
|
|
|
|
|
|
|
|
%unignoreall
|
|
|
|
|
|
|
|
|
|
// ============= Custom python wrappers around C++ objects ==============
|
|
|
|
|
// (this section must be after the constraint_solver*.h %includes)
|
|
|
|
|
|
2014-05-22 17:37:21 +00:00
|
|
|
%pythoncode {
|
2015-12-07 13:27:18 +01:00
|
|
|
class PyDecision(Decision):
|
|
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
|
Decision.__init__(self)
|
|
|
|
|
|
|
|
|
|
def ApplyWrapper(self, solver):
|
|
|
|
|
try:
|
|
|
|
|
self.Apply(solver)
|
|
|
|
|
except Exception as e:
|
|
|
|
|
if 'CP Solver fail' in str(e):
|
|
|
|
|
solver.ShouldFail()
|
|
|
|
|
else:
|
|
|
|
|
raise
|
|
|
|
|
|
|
|
|
|
def RefuteWrapper(self, solver):
|
|
|
|
|
try:
|
|
|
|
|
self.Refute(solver)
|
|
|
|
|
except Exception as e:
|
|
|
|
|
if 'CP Solver fail' in str(e):
|
|
|
|
|
solver.ShouldFail()
|
|
|
|
|
else:
|
|
|
|
|
raise
|
|
|
|
|
|
|
|
|
|
def DebugString(self):
|
|
|
|
|
return "PyDecision"
|
|
|
|
|
|
|
|
|
|
|
2015-12-07 13:05:16 +01:00
|
|
|
class PyDecisionBuilder(DecisionBuilder):
|
|
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
|
DecisionBuilder.__init__(self)
|
2014-07-09 11:17:29 +00:00
|
|
|
|
2014-05-22 17:37:21 +00:00
|
|
|
def NextWrapper(self, solver):
|
|
|
|
|
try:
|
2014-07-09 11:17:29 +00:00
|
|
|
return self.Next(solver)
|
|
|
|
|
except Exception as e:
|
|
|
|
|
if 'CP Solver fail' in str(e):
|
|
|
|
|
return solver.FailDecision()
|
|
|
|
|
else:
|
|
|
|
|
raise
|
2014-05-22 17:37:21 +00:00
|
|
|
|
|
|
|
|
def DebugString(self):
|
|
|
|
|
return "PyDecisionBuilder"
|
|
|
|
|
|
|
|
|
|
|
2016-01-05 22:35:02 +01:00
|
|
|
class PyDemon(Demon):
|
2015-12-07 13:05:16 +01:00
|
|
|
|
2016-01-05 22:35:02 +01:00
|
|
|
def RunWrapper(self, solver):
|
2014-05-22 17:37:21 +00:00
|
|
|
try:
|
2016-01-05 22:35:02 +01:00
|
|
|
self.Run(solver)
|
2014-07-09 11:17:29 +00:00
|
|
|
except Exception as e:
|
|
|
|
|
if 'CP Solver fail' in str(e):
|
2016-01-05 22:35:02 +01:00
|
|
|
solver.ShouldFail()
|
2014-07-09 11:17:29 +00:00
|
|
|
else:
|
|
|
|
|
raise
|
2014-05-22 17:37:21 +00:00
|
|
|
|
|
|
|
|
def DebugString(self):
|
2016-01-05 22:35:02 +01:00
|
|
|
return "PyDemon"
|
2014-05-22 17:37:21 +00:00
|
|
|
|
2016-01-05 22:35:02 +01:00
|
|
|
class PyConstraintDemon(PyDemon):
|
2014-05-22 17:37:21 +00:00
|
|
|
|
2016-01-05 22:35:02 +01:00
|
|
|
def __init__(self, ct, method, delayed, *args):
|
|
|
|
|
PyDemon.__init__(self)
|
|
|
|
|
self.__constraint = ct
|
|
|
|
|
self.__method = method
|
|
|
|
|
self.__delayed = delayed
|
|
|
|
|
self.__args = args
|
2014-06-15 17:24:48 +00:00
|
|
|
|
2016-01-05 22:35:02 +01:00
|
|
|
def Run(self, solver):
|
|
|
|
|
self.__method(self.__constraint, *self.__args)
|
|
|
|
|
|
|
|
|
|
def Priority(self):
|
|
|
|
|
return (pywrapcp.Solver.DELAYED_PRIORITY if self.__delayed
|
|
|
|
|
else pywrapcp.Solver.NORMAL_PRIORITY)
|
|
|
|
|
|
|
|
|
|
def DebugString(self):
|
|
|
|
|
return 'PyConstraintDemon'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PyConstraint(Constraint):
|
|
|
|
|
|
|
|
|
|
def __init__(self, solver):
|
|
|
|
|
Constraint.__init__(self, solver)
|
|
|
|
|
self.__demons = []
|
|
|
|
|
|
|
|
|
|
def Demon(self, method, *args):
|
|
|
|
|
demon = PyConstraintDemon(self, method, False, *args)
|
|
|
|
|
self.__demons.append(demon)
|
|
|
|
|
return demon
|
|
|
|
|
|
|
|
|
|
def DelayedDemon(self, method, *args):
|
|
|
|
|
demon = PyConstraintDemon(self, method, True, *args)
|
|
|
|
|
self.__demons.append(demon)
|
|
|
|
|
return demon
|
|
|
|
|
|
|
|
|
|
def InitialPropagateWrapper(self):
|
2014-05-22 17:37:21 +00:00
|
|
|
try:
|
2016-01-05 22:35:02 +01:00
|
|
|
self.InitialPropagate()
|
2014-07-09 11:17:29 +00:00
|
|
|
except Exception as e:
|
|
|
|
|
if 'CP Solver fail' in str(e):
|
2016-01-05 22:35:02 +01:00
|
|
|
self.solver().ShouldFail()
|
2014-07-09 11:17:29 +00:00
|
|
|
else:
|
|
|
|
|
raise
|
2014-05-22 17:37:21 +00:00
|
|
|
|
|
|
|
|
def DebugString(self):
|
2016-01-05 22:35:02 +01:00
|
|
|
return "PyConstraint"
|
|
|
|
|
|
|
|
|
|
|
2014-07-09 11:17:29 +00:00
|
|
|
} // %pythoncode
|