working LS in python with filters

This commit is contained in:
laurent.perron@gmail.com
2014-06-15 21:02:58 +00:00
parent e03c71b50d
commit 6cda031e80
2 changed files with 5 additions and 5 deletions

View File

@@ -65,8 +65,9 @@ class SumFilter(pywrapcp.IntVarLocalSearchFilter):
new_sum = self.__sum
for i in range(solution_delta_size):
element = solution_delta.Element(index)
touched_var = self.FindIndex(element.Var())
element = solution_delta.Element(i)
int_var = element.Var()
touched_var = self.IndexFromVar(int_var)
old_value = self.Value(touched_var)
new_value = element.Value()
new_sum += new_value - old_value

View File

@@ -156,7 +156,6 @@ static bool PyCallbackBool(PyObject* pyfunc) {
%feature("nodirector") operations_research::SequenceVarLocalSearchOperator::Start;
%feature("director") operations_research::IntVarLocalSearchFilter;
%feature("nodirector") operations_research::IntVarLocalSearchFilter::Start;
%ignore operations_research::IntVarLocalSearchFilter::FindIndex;
// We *do* need to use SWIGTYPE_... descriptor directly in embedded C++ code:
// the recommended replacement $descriptor(...) is only available within
@@ -1122,8 +1121,8 @@ static void SetPythonFlags(bool trace_propagation,
}
%extend IntVarLocalSearchFilter {
int FindIndex(IntVar* const var) {
index = -1;
int64 IndexFromVar(IntVar* const var) const {
int64 index = -1;
self->FindIndex(var, &index);
return index;
}