add python API for NotMember

This commit is contained in:
Laurent Perron
2016-06-14 17:03:20 +02:00
parent b5ff90cb5c
commit c20142fdde
2 changed files with 8 additions and 1 deletions

View File

@@ -491,6 +491,10 @@ PY_STRINGIFY_DEBUGSTRING(Decision);
Constraint* Member(const std::vector<int64>& values) {
return $self->solver()->MakeMemberCt($self->Var(), values);
}
Constraint* NotMember(const std::vector<int64>& starts,
const std::vector<int64>& ends) {
return $self->solver()->MakeNotMemberCt($self, starts, ends);
}
}
// Add arithmetic operators to integer expressions.
@@ -2240,3 +2244,4 @@ class PyConstraint(Constraint):
} // %pythoncode

View File

@@ -31,7 +31,9 @@ namespace operations_research {
// defined in base/swig/python-swig.cc seems to cause issues, so we can't
// use a generic, templated type checker.
%define PY_LIST_OUTPUT_TYPEMAP(type, checker, py_converter)
%typecheck(SWIG_TYPECHECK_POINTER) const std::vector<type>& {
%typecheck(SWIG_TYPECHECK_POINTER) const std::vector<type>&,
std::vector<type>,
const std::vector<type>* {
if (!PyTuple_Check($input) && !PyList_Check($input)) {
$1 = 0;
} else {