diff --git a/choco-solver-capi b/choco-solver-capi index d11a978..a2c717a 160000 --- a/choco-solver-capi +++ b/choco-solver-capi @@ -1 +1 @@ -Subproject commit d11a978e9c6d9e3f75fa1c408e8b643a94604e88 +Subproject commit a2c717ac07072b08b630808283db29982c32acee diff --git a/pychoco/backend.c b/pychoco/backend.c index 39fb9f4..2d30b16 100644 --- a/pychoco/backend.c +++ b/pychoco/backend.c @@ -160,7 +160,6 @@ int get_int_val(void* solutionHandle, void* intVarHandle) { LAZY_THREAD_ATTACH return Java_org_chocosolver_capi_SolutionApi_getIntVal(thread, solutionHandle, intVarHandle); } - void* get_set_val(void* solutionHandle, void* setVarHandle) { LAZY_THREAD_ATTACH return Java_org_chocosolver_capi_SolutionApi_getSetVal(thread, solutionHandle, setVarHandle); @@ -187,32 +186,26 @@ void* intvar_sii(void* modelHandle, char* name, int lb, int ub) { LAZY_THREAD_ATTACH return Java_org_chocosolver_capi_IntVarApi_intVar_sii(thread, modelHandle, name, lb, ub); } - void* intvar_siib(void* modelHandle, char* name, int lb, int ub, int boundedDomain) { LAZY_THREAD_ATTACH return Java_org_chocosolver_capi_IntVarApi_intVar_siib(thread, modelHandle, name, lb, ub, boundedDomain); } - void* intvar_ii(void* modelHandle, int lb, int ub) { LAZY_THREAD_ATTACH return Java_org_chocosolver_capi_IntVarApi_intVar_ii(thread, modelHandle, lb, ub); } - void* intvar_iib(void* modelHandle, int lb, int ub, int boundedDomain) { LAZY_THREAD_ATTACH return Java_org_chocosolver_capi_IntVarApi_intVar_iib(thread, modelHandle, lb, ub, boundedDomain); } - void* intvar_s_arr(void* modelHandle, char* name, void* valuesHandle) { LAZY_THREAD_ATTACH return Java_org_chocosolver_capi_IntVarApi_intVar_s_arr(thread, modelHandle, name, valuesHandle); } - void* intvar_arr(void* modelHandle, void* valuesHandle) { LAZY_THREAD_ATTACH return Java_org_chocosolver_capi_IntVarApi_intVar_arr(thread, modelHandle, valuesHandle); } - void* intvar_i(void* modelHandle, int value) { LAZY_THREAD_ATTACH return Java_org_chocosolver_capi_IntVarApi_intVar_i(thread, modelHandle, value); @@ -363,10 +356,95 @@ int is_satisfied(void* constraintHandle) { // Reification +void if_then_else(void* modelHandle, void* ifHandle, void* thenHandle, void* elseHandle) { + LAZY_THREAD_ATTACH + Java_org_chocosolver_capi_ReificationApi_if_then_else(thread, modelHandle, ifHandle, thenHandle, elseHandle); +} +void if_then_else_bool(void* modelHandle, void* ifHandle, void* thenHandle, void* elseHandle) { + LAZY_THREAD_ATTACH + Java_org_chocosolver_capi_ReificationApi_if_then_else_bool(thread, modelHandle, ifHandle, thenHandle, elseHandle); +} void if_then(void* modelHandle, void* ifHandle, void* thenHandle){ LAZY_THREAD_ATTACH Java_org_chocosolver_capi_ReificationApi_if_then(thread, modelHandle, ifHandle, thenHandle); } +void if_then_bool(void* modelHandle, void* ifHandle, void* thenHandle) { + LAZY_THREAD_ATTACH + Java_org_chocosolver_capi_ReificationApi_if_then_bool(thread, modelHandle, ifHandle, thenHandle); +} +void if_only_if(void* modelHandle, void* cstr1Handle, void* cstr2Handle) { + LAZY_THREAD_ATTACH + Java_org_chocosolver_capi_ReificationApi_if_only_if(thread, modelHandle, cstr1Handle, cstr2Handle); +} +void reification(void* modelHandle, void* boolVarHandle, void* cstrHandle) { + LAZY_THREAD_ATTACH + Java_org_chocosolver_capi_ReificationApi_reification(thread, modelHandle, boolVarHandle, cstrHandle); +} +void reify_x_eq_c(void* modelHandle, void* xHandle, int c, void* bHandle) { + LAZY_THREAD_ATTACH + Java_org_chocosolver_capi_ReificationApi_reify_x_eq_c(thread, modelHandle, xHandle, c, bHandle); +} +void reify_x_ne_c(void* modelHandle, void* xHandle, int c, void* bHandle) { + LAZY_THREAD_ATTACH + Java_org_chocosolver_capi_ReificationApi_reify_x_ne_c(thread, modelHandle, xHandle, c, bHandle); +} +void reify_x_eq_y(void* modelHandle, void* xHandle, void* yHandle, void* bHandle) { + LAZY_THREAD_ATTACH + Java_org_chocosolver_capi_ReificationApi_reify_x_eq_y(thread, modelHandle, xHandle, yHandle, bHandle); +} +void reify_x_ne_y(void* modelHandle, void* xHandle, void* yHandle, void* bHandle) { + LAZY_THREAD_ATTACH + Java_org_chocosolver_capi_ReificationApi_reify_x_ne_y(thread, modelHandle, xHandle, yHandle, bHandle); +} +void reify_x_eq_yc(void* modelHandle, void* xHandle, void* yHandle, int c, void* bHandle) { + LAZY_THREAD_ATTACH + Java_org_chocosolver_capi_ReificationApi_reify_x_eq_yc(thread, modelHandle, xHandle, yHandle, c, bHandle); +} +void reify_x_ne_yc(void* modelHandle, void* xHandle, void* yHandle, int c, void* bHandle) { + LAZY_THREAD_ATTACH + Java_org_chocosolver_capi_ReificationApi_reify_x_ne_yc(thread, modelHandle, xHandle, yHandle, c, bHandle); +} +void reify_x_lt_c(void* modelHandle, void* xHandle, int c, void* bHandle) { + LAZY_THREAD_ATTACH + Java_org_chocosolver_capi_ReificationApi_reify_x_lt_c(thread, modelHandle, xHandle, c, bHandle); +} +void reify_x_gt_c(void* modelHandle, void* xHandle, int c, void* bHandle) { + LAZY_THREAD_ATTACH + Java_org_chocosolver_capi_ReificationApi_reify_x_gt_c(thread, modelHandle, xHandle, c, bHandle); +} +void reify_x_lt_y(void* modelHandle, void* xHandle, void* yHandle, void* bHandle) { + LAZY_THREAD_ATTACH + Java_org_chocosolver_capi_ReificationApi_reify_x_lt_y(thread, modelHandle, xHandle, yHandle, bHandle); +} +void reify_x_gt_y(void* modelHandle, void* xHandle, void* yHandle, void* bHandle) { + LAZY_THREAD_ATTACH + Java_org_chocosolver_capi_ReificationApi_reify_x_gt_y(thread, modelHandle, xHandle, yHandle, bHandle); +} +void reify_x_le_y(void* modelHandle, void* xHandle, void* yHandle, void* bHandle) { + LAZY_THREAD_ATTACH + Java_org_chocosolver_capi_ReificationApi_reify_x_le_y(thread, modelHandle, xHandle, yHandle, bHandle); +} +void reify_x_ge_y(void* modelHandle, void* xHandle, void* yHandle, void* bHandle) { + LAZY_THREAD_ATTACH + Java_org_chocosolver_capi_ReificationApi_reify_x_ge_y(thread, modelHandle, xHandle, yHandle, bHandle); +} +void reify_x_lt_yc(void* modelHandle, void* xHandle, void* yHandle, int c, void* bHandle) { + LAZY_THREAD_ATTACH + Java_org_chocosolver_capi_ReificationApi_reify_x_lt_yc(thread, modelHandle, xHandle, yHandle, c, bHandle); +} +void reify_x_gt_yc(void* modelHandle, void* xHandle, void* yHandle, int c, void* bHandle) { + LAZY_THREAD_ATTACH + Java_org_chocosolver_capi_ReificationApi_reify_x_gt_yc(thread, modelHandle, xHandle, yHandle, c, bHandle); +} +void reify_x_in_s(void* modelHandle, void* xHandle, void* sArrayHandle, void* bHandle) { + LAZY_THREAD_ATTACH + Java_org_chocosolver_capi_ReificationApi_reify_x_in_s(thread, modelHandle, xHandle, sArrayHandle, bHandle); +} +void reify_x_not_in_s(void* modelHandle, void* xHandle, void* sArrayHandle, void* bHandle) { + LAZY_THREAD_ATTACH + Java_org_chocosolver_capi_ReificationApi_reify_x_not_in_s(thread, modelHandle, xHandle, sArrayHandle, bHandle); +} + // IntVar and BoolVar constraints diff --git a/pychoco/backend.h b/pychoco/backend.h index 01a748c..5791188 100644 --- a/pychoco/backend.h +++ b/pychoco/backend.h @@ -110,7 +110,28 @@ int is_satisfied(void*); // Reification +void if_then_else(void*, void*, void*, void*); +void if_then_else_bool(void*, void*, void*, void*); void if_then(void*, void*, void*); +void if_then_bool(void*, void*, void*); +void if_only_if(void*, void*, void*); +void reification(void*, void*, void*); +void reify_x_eq_c(void*, void*, int, void*); +void reify_x_ne_c(void*, void*, int, void*); +void reify_x_eq_y(void*, void*, void*, void*); +void reify_x_ne_y(void*, void*, void*, void*); +void reify_x_eq_yc(void*, void*, void*, int, void*); +void reify_x_ne_yc(void*, void*, void*, int, void*); +void reify_x_lt_c(void*, void*, int, void*); +void reify_x_gt_c(void*, void*, int, void*); +void reify_x_lt_y(void*, void*, void*, void*); +void reify_x_gt_y(void*, void*, void*, void*); +void reify_x_le_y(void*, void*, void*, void*); +void reify_x_ge_y(void*, void*, void*, void*); +void reify_x_lt_yc(void*, void*, void*, int, void*); +void reify_x_gt_yc(void*, void*, void*, int, void*); +void reify_x_in_s(void*, void*, void*, void*); +void reify_x_not_in_s(void*, void*, void*, void*); // IntVar and BoolVar constraints diff --git a/pychoco/backend.i b/pychoco/backend.i index ab61845..a55c3c1 100644 --- a/pychoco/backend.i +++ b/pychoco/backend.i @@ -148,7 +148,28 @@ int is_satisfied(void*); // Reification +void if_then_else(void*, void*, void*, void*); +void if_then_else_bool(void*, void*, void*, void*); void if_then(void*, void*, void*); +void if_then_bool(void*, void*, void*); +void if_only_if(void*, void*, void*); +void reification(void*, void*, void*); +void reify_x_eq_c(void*, void*, int, void*); +void reify_x_ne_c(void*, void*, int, void*); +void reify_x_eq_y(void*, void*, void*, void*); +void reify_x_ne_y(void*, void*, void*, void*); +void reify_x_eq_yc(void*, void*, void*, int, void*); +void reify_x_ne_yc(void*, void*, void*, int, void*); +void reify_x_lt_c(void*, void*, int, void*); +void reify_x_gt_c(void*, void*, int, void*); +void reify_x_lt_y(void*, void*, void*, void*); +void reify_x_gt_y(void*, void*, void*, void*); +void reify_x_le_y(void*, void*, void*, void*); +void reify_x_ge_y(void*, void*, void*, void*); +void reify_x_lt_yc(void*, void*, void*, int, void*); +void reify_x_gt_yc(void*, void*, void*, int, void*); +void reify_x_in_s(void*, void*, void*, void*); +void reify_x_not_in_s(void*, void*, void*, void*); // IntVar and BoolVar constraints diff --git a/pychoco/backend.py b/pychoco/backend.py index 3513d10..cc5e4b9 100644 --- a/pychoco/backend.py +++ b/pychoco/backend.py @@ -269,11 +269,74 @@ def implies(arg1, arg2): def implied_by(arg1, arg2): return _backend.implied_by(arg1, arg2) +def is_satisfied(arg1): + return _backend.is_satisfied(arg1) + +def if_then_else(arg1, arg2, arg3, arg4): + return _backend.if_then_else(arg1, arg2, arg3, arg4) + +def if_then_else_bool(arg1, arg2, arg3, arg4): + return _backend.if_then_else_bool(arg1, arg2, arg3, arg4) + def if_then(arg1, arg2, arg3): return _backend.if_then(arg1, arg2, arg3) -def is_satisfied(arg1): - return _backend.is_satisfied(arg1) +def if_then_bool(arg1, arg2, arg3): + return _backend.if_then_bool(arg1, arg2, arg3) + +def if_only_if(arg1, arg2, arg3): + return _backend.if_only_if(arg1, arg2, arg3) + +def reification(arg1, arg2, arg3): + return _backend.reification(arg1, arg2, arg3) + +def reify_x_eq_c(arg1, arg2, arg3, arg4): + return _backend.reify_x_eq_c(arg1, arg2, arg3, arg4) + +def reify_x_ne_c(arg1, arg2, arg3, arg4): + return _backend.reify_x_ne_c(arg1, arg2, arg3, arg4) + +def reify_x_eq_y(arg1, arg2, arg3, arg4): + return _backend.reify_x_eq_y(arg1, arg2, arg3, arg4) + +def reify_x_ne_y(arg1, arg2, arg3, arg4): + return _backend.reify_x_ne_y(arg1, arg2, arg3, arg4) + +def reify_x_eq_yc(arg1, arg2, arg3, arg4, arg5): + return _backend.reify_x_eq_yc(arg1, arg2, arg3, arg4, arg5) + +def reify_x_ne_yc(arg1, arg2, arg3, arg4, arg5): + return _backend.reify_x_ne_yc(arg1, arg2, arg3, arg4, arg5) + +def reify_x_lt_c(arg1, arg2, arg3, arg4): + return _backend.reify_x_lt_c(arg1, arg2, arg3, arg4) + +def reify_x_gt_c(arg1, arg2, arg3, arg4): + return _backend.reify_x_gt_c(arg1, arg2, arg3, arg4) + +def reify_x_lt_y(arg1, arg2, arg3, arg4): + return _backend.reify_x_lt_y(arg1, arg2, arg3, arg4) + +def reify_x_gt_y(arg1, arg2, arg3, arg4): + return _backend.reify_x_gt_y(arg1, arg2, arg3, arg4) + +def reify_x_le_y(arg1, arg2, arg3, arg4): + return _backend.reify_x_le_y(arg1, arg2, arg3, arg4) + +def reify_x_ge_y(arg1, arg2, arg3, arg4): + return _backend.reify_x_ge_y(arg1, arg2, arg3, arg4) + +def reify_x_lt_yc(arg1, arg2, arg3, arg4, arg5): + return _backend.reify_x_lt_yc(arg1, arg2, arg3, arg4, arg5) + +def reify_x_gt_yc(arg1, arg2, arg3, arg4, arg5): + return _backend.reify_x_gt_yc(arg1, arg2, arg3, arg4, arg5) + +def reify_x_in_s(arg1, arg2, arg3, arg4): + return _backend.reify_x_in_s(arg1, arg2, arg3, arg4) + +def reify_x_not_in_s(arg1, arg2, arg3, arg4): + return _backend.reify_x_not_in_s(arg1, arg2, arg3, arg4) def arithm_iv_cst(arg1, arg2, arg3, arg4): return _backend.arithm_iv_cst(arg1, arg2, arg3, arg4) diff --git a/pychoco/backend_wrap.c b/pychoco/backend_wrap.c index 9e35a10..b393e58 100644 --- a/pychoco/backend_wrap.c +++ b/pychoco/backend_wrap.c @@ -4897,6 +4897,101 @@ SWIGINTERN PyObject *_wrap_implied_by(PyObject *SWIGUNUSEDPARM(self), PyObject * } +SWIGINTERN PyObject *_wrap_is_satisfied(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + void *arg1 = (void *) 0 ; + int res1 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0],SWIG_as_voidptrptr(&arg1), 0, 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "is_satisfied" "', argument " "1"" of type '" "void *""'"); + } + result = (int)is_satisfied(arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_if_then_else(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + void *arg1 = (void *) 0 ; + void *arg2 = (void *) 0 ; + void *arg3 = (void *) 0 ; + void *arg4 = (void *) 0 ; + int res1 ; + int res2 ; + int res3 ; + int res4 ; + PyObject *swig_obj[4] ; + + if (!SWIG_Python_UnpackTuple(args, "if_then_else", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0],SWIG_as_voidptrptr(&arg1), 0, 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "if_then_else" "', argument " "1"" of type '" "void *""'"); + } + res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "if_then_else" "', argument " "2"" of type '" "void *""'"); + } + res3 = SWIG_ConvertPtr(swig_obj[2],SWIG_as_voidptrptr(&arg3), 0, 0); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "if_then_else" "', argument " "3"" of type '" "void *""'"); + } + res4 = SWIG_ConvertPtr(swig_obj[3],SWIG_as_voidptrptr(&arg4), 0, 0); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "if_then_else" "', argument " "4"" of type '" "void *""'"); + } + if_then_else(arg1,arg2,arg3,arg4); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_if_then_else_bool(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + void *arg1 = (void *) 0 ; + void *arg2 = (void *) 0 ; + void *arg3 = (void *) 0 ; + void *arg4 = (void *) 0 ; + int res1 ; + int res2 ; + int res3 ; + int res4 ; + PyObject *swig_obj[4] ; + + if (!SWIG_Python_UnpackTuple(args, "if_then_else_bool", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0],SWIG_as_voidptrptr(&arg1), 0, 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "if_then_else_bool" "', argument " "1"" of type '" "void *""'"); + } + res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "if_then_else_bool" "', argument " "2"" of type '" "void *""'"); + } + res3 = SWIG_ConvertPtr(swig_obj[2],SWIG_as_voidptrptr(&arg3), 0, 0); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "if_then_else_bool" "', argument " "3"" of type '" "void *""'"); + } + res4 = SWIG_ConvertPtr(swig_obj[3],SWIG_as_voidptrptr(&arg4), 0, 0); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "if_then_else_bool" "', argument " "4"" of type '" "void *""'"); + } + if_then_else_bool(arg1,arg2,arg3,arg4); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *_wrap_if_then(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; void *arg1 = (void *) 0 ; @@ -4905,22 +5000,472 @@ SWIGINTERN PyObject *_wrap_if_then(PyObject *SWIGUNUSEDPARM(self), PyObject *arg int res1 ; int res2 ; int res3 ; - PyObject *swig_obj[3] ; + PyObject *swig_obj[3] ; + + if (!SWIG_Python_UnpackTuple(args, "if_then", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0],SWIG_as_voidptrptr(&arg1), 0, 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "if_then" "', argument " "1"" of type '" "void *""'"); + } + res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "if_then" "', argument " "2"" of type '" "void *""'"); + } + res3 = SWIG_ConvertPtr(swig_obj[2],SWIG_as_voidptrptr(&arg3), 0, 0); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "if_then" "', argument " "3"" of type '" "void *""'"); + } + if_then(arg1,arg2,arg3); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_if_then_bool(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + void *arg1 = (void *) 0 ; + void *arg2 = (void *) 0 ; + void *arg3 = (void *) 0 ; + int res1 ; + int res2 ; + int res3 ; + PyObject *swig_obj[3] ; + + if (!SWIG_Python_UnpackTuple(args, "if_then_bool", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0],SWIG_as_voidptrptr(&arg1), 0, 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "if_then_bool" "', argument " "1"" of type '" "void *""'"); + } + res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "if_then_bool" "', argument " "2"" of type '" "void *""'"); + } + res3 = SWIG_ConvertPtr(swig_obj[2],SWIG_as_voidptrptr(&arg3), 0, 0); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "if_then_bool" "', argument " "3"" of type '" "void *""'"); + } + if_then_bool(arg1,arg2,arg3); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_if_only_if(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + void *arg1 = (void *) 0 ; + void *arg2 = (void *) 0 ; + void *arg3 = (void *) 0 ; + int res1 ; + int res2 ; + int res3 ; + PyObject *swig_obj[3] ; + + if (!SWIG_Python_UnpackTuple(args, "if_only_if", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0],SWIG_as_voidptrptr(&arg1), 0, 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "if_only_if" "', argument " "1"" of type '" "void *""'"); + } + res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "if_only_if" "', argument " "2"" of type '" "void *""'"); + } + res3 = SWIG_ConvertPtr(swig_obj[2],SWIG_as_voidptrptr(&arg3), 0, 0); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "if_only_if" "', argument " "3"" of type '" "void *""'"); + } + if_only_if(arg1,arg2,arg3); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_reification(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + void *arg1 = (void *) 0 ; + void *arg2 = (void *) 0 ; + void *arg3 = (void *) 0 ; + int res1 ; + int res2 ; + int res3 ; + PyObject *swig_obj[3] ; + + if (!SWIG_Python_UnpackTuple(args, "reification", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0],SWIG_as_voidptrptr(&arg1), 0, 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "reification" "', argument " "1"" of type '" "void *""'"); + } + res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "reification" "', argument " "2"" of type '" "void *""'"); + } + res3 = SWIG_ConvertPtr(swig_obj[2],SWIG_as_voidptrptr(&arg3), 0, 0); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "reification" "', argument " "3"" of type '" "void *""'"); + } + reification(arg1,arg2,arg3); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_reify_x_eq_c(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + void *arg1 = (void *) 0 ; + void *arg2 = (void *) 0 ; + int arg3 ; + void *arg4 = (void *) 0 ; + int res1 ; + int res2 ; + int val3 ; + int ecode3 = 0 ; + int res4 ; + PyObject *swig_obj[4] ; + + if (!SWIG_Python_UnpackTuple(args, "reify_x_eq_c", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0],SWIG_as_voidptrptr(&arg1), 0, 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "reify_x_eq_c" "', argument " "1"" of type '" "void *""'"); + } + res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "reify_x_eq_c" "', argument " "2"" of type '" "void *""'"); + } + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "reify_x_eq_c" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + res4 = SWIG_ConvertPtr(swig_obj[3],SWIG_as_voidptrptr(&arg4), 0, 0); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "reify_x_eq_c" "', argument " "4"" of type '" "void *""'"); + } + reify_x_eq_c(arg1,arg2,arg3,arg4); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_reify_x_ne_c(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + void *arg1 = (void *) 0 ; + void *arg2 = (void *) 0 ; + int arg3 ; + void *arg4 = (void *) 0 ; + int res1 ; + int res2 ; + int val3 ; + int ecode3 = 0 ; + int res4 ; + PyObject *swig_obj[4] ; + + if (!SWIG_Python_UnpackTuple(args, "reify_x_ne_c", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0],SWIG_as_voidptrptr(&arg1), 0, 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "reify_x_ne_c" "', argument " "1"" of type '" "void *""'"); + } + res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "reify_x_ne_c" "', argument " "2"" of type '" "void *""'"); + } + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "reify_x_ne_c" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + res4 = SWIG_ConvertPtr(swig_obj[3],SWIG_as_voidptrptr(&arg4), 0, 0); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "reify_x_ne_c" "', argument " "4"" of type '" "void *""'"); + } + reify_x_ne_c(arg1,arg2,arg3,arg4); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_reify_x_eq_y(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + void *arg1 = (void *) 0 ; + void *arg2 = (void *) 0 ; + void *arg3 = (void *) 0 ; + void *arg4 = (void *) 0 ; + int res1 ; + int res2 ; + int res3 ; + int res4 ; + PyObject *swig_obj[4] ; + + if (!SWIG_Python_UnpackTuple(args, "reify_x_eq_y", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0],SWIG_as_voidptrptr(&arg1), 0, 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "reify_x_eq_y" "', argument " "1"" of type '" "void *""'"); + } + res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "reify_x_eq_y" "', argument " "2"" of type '" "void *""'"); + } + res3 = SWIG_ConvertPtr(swig_obj[2],SWIG_as_voidptrptr(&arg3), 0, 0); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "reify_x_eq_y" "', argument " "3"" of type '" "void *""'"); + } + res4 = SWIG_ConvertPtr(swig_obj[3],SWIG_as_voidptrptr(&arg4), 0, 0); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "reify_x_eq_y" "', argument " "4"" of type '" "void *""'"); + } + reify_x_eq_y(arg1,arg2,arg3,arg4); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_reify_x_ne_y(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + void *arg1 = (void *) 0 ; + void *arg2 = (void *) 0 ; + void *arg3 = (void *) 0 ; + void *arg4 = (void *) 0 ; + int res1 ; + int res2 ; + int res3 ; + int res4 ; + PyObject *swig_obj[4] ; + + if (!SWIG_Python_UnpackTuple(args, "reify_x_ne_y", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0],SWIG_as_voidptrptr(&arg1), 0, 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "reify_x_ne_y" "', argument " "1"" of type '" "void *""'"); + } + res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "reify_x_ne_y" "', argument " "2"" of type '" "void *""'"); + } + res3 = SWIG_ConvertPtr(swig_obj[2],SWIG_as_voidptrptr(&arg3), 0, 0); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "reify_x_ne_y" "', argument " "3"" of type '" "void *""'"); + } + res4 = SWIG_ConvertPtr(swig_obj[3],SWIG_as_voidptrptr(&arg4), 0, 0); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "reify_x_ne_y" "', argument " "4"" of type '" "void *""'"); + } + reify_x_ne_y(arg1,arg2,arg3,arg4); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_reify_x_eq_yc(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + void *arg1 = (void *) 0 ; + void *arg2 = (void *) 0 ; + void *arg3 = (void *) 0 ; + int arg4 ; + void *arg5 = (void *) 0 ; + int res1 ; + int res2 ; + int res3 ; + int val4 ; + int ecode4 = 0 ; + int res5 ; + PyObject *swig_obj[5] ; + + if (!SWIG_Python_UnpackTuple(args, "reify_x_eq_yc", 5, 5, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0],SWIG_as_voidptrptr(&arg1), 0, 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "reify_x_eq_yc" "', argument " "1"" of type '" "void *""'"); + } + res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "reify_x_eq_yc" "', argument " "2"" of type '" "void *""'"); + } + res3 = SWIG_ConvertPtr(swig_obj[2],SWIG_as_voidptrptr(&arg3), 0, 0); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "reify_x_eq_yc" "', argument " "3"" of type '" "void *""'"); + } + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "reify_x_eq_yc" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + res5 = SWIG_ConvertPtr(swig_obj[4],SWIG_as_voidptrptr(&arg5), 0, 0); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "reify_x_eq_yc" "', argument " "5"" of type '" "void *""'"); + } + reify_x_eq_yc(arg1,arg2,arg3,arg4,arg5); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_reify_x_ne_yc(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + void *arg1 = (void *) 0 ; + void *arg2 = (void *) 0 ; + void *arg3 = (void *) 0 ; + int arg4 ; + void *arg5 = (void *) 0 ; + int res1 ; + int res2 ; + int res3 ; + int val4 ; + int ecode4 = 0 ; + int res5 ; + PyObject *swig_obj[5] ; + + if (!SWIG_Python_UnpackTuple(args, "reify_x_ne_yc", 5, 5, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0],SWIG_as_voidptrptr(&arg1), 0, 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "reify_x_ne_yc" "', argument " "1"" of type '" "void *""'"); + } + res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "reify_x_ne_yc" "', argument " "2"" of type '" "void *""'"); + } + res3 = SWIG_ConvertPtr(swig_obj[2],SWIG_as_voidptrptr(&arg3), 0, 0); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "reify_x_ne_yc" "', argument " "3"" of type '" "void *""'"); + } + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "reify_x_ne_yc" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + res5 = SWIG_ConvertPtr(swig_obj[4],SWIG_as_voidptrptr(&arg5), 0, 0); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "reify_x_ne_yc" "', argument " "5"" of type '" "void *""'"); + } + reify_x_ne_yc(arg1,arg2,arg3,arg4,arg5); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_reify_x_lt_c(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + void *arg1 = (void *) 0 ; + void *arg2 = (void *) 0 ; + int arg3 ; + void *arg4 = (void *) 0 ; + int res1 ; + int res2 ; + int val3 ; + int ecode3 = 0 ; + int res4 ; + PyObject *swig_obj[4] ; + + if (!SWIG_Python_UnpackTuple(args, "reify_x_lt_c", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0],SWIG_as_voidptrptr(&arg1), 0, 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "reify_x_lt_c" "', argument " "1"" of type '" "void *""'"); + } + res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "reify_x_lt_c" "', argument " "2"" of type '" "void *""'"); + } + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "reify_x_lt_c" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + res4 = SWIG_ConvertPtr(swig_obj[3],SWIG_as_voidptrptr(&arg4), 0, 0); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "reify_x_lt_c" "', argument " "4"" of type '" "void *""'"); + } + reify_x_lt_c(arg1,arg2,arg3,arg4); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_reify_x_gt_c(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + void *arg1 = (void *) 0 ; + void *arg2 = (void *) 0 ; + int arg3 ; + void *arg4 = (void *) 0 ; + int res1 ; + int res2 ; + int val3 ; + int ecode3 = 0 ; + int res4 ; + PyObject *swig_obj[4] ; + + if (!SWIG_Python_UnpackTuple(args, "reify_x_gt_c", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0],SWIG_as_voidptrptr(&arg1), 0, 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "reify_x_gt_c" "', argument " "1"" of type '" "void *""'"); + } + res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "reify_x_gt_c" "', argument " "2"" of type '" "void *""'"); + } + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "reify_x_gt_c" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + res4 = SWIG_ConvertPtr(swig_obj[3],SWIG_as_voidptrptr(&arg4), 0, 0); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "reify_x_gt_c" "', argument " "4"" of type '" "void *""'"); + } + reify_x_gt_c(arg1,arg2,arg3,arg4); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_reify_x_lt_y(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + void *arg1 = (void *) 0 ; + void *arg2 = (void *) 0 ; + void *arg3 = (void *) 0 ; + void *arg4 = (void *) 0 ; + int res1 ; + int res2 ; + int res3 ; + int res4 ; + PyObject *swig_obj[4] ; - if (!SWIG_Python_UnpackTuple(args, "if_then", 3, 3, swig_obj)) SWIG_fail; + if (!SWIG_Python_UnpackTuple(args, "reify_x_lt_y", 4, 4, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0],SWIG_as_voidptrptr(&arg1), 0, 0); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "if_then" "', argument " "1"" of type '" "void *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "reify_x_lt_y" "', argument " "1"" of type '" "void *""'"); } res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "if_then" "', argument " "2"" of type '" "void *""'"); + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "reify_x_lt_y" "', argument " "2"" of type '" "void *""'"); } res3 = SWIG_ConvertPtr(swig_obj[2],SWIG_as_voidptrptr(&arg3), 0, 0); if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "if_then" "', argument " "3"" of type '" "void *""'"); + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "reify_x_lt_y" "', argument " "3"" of type '" "void *""'"); } - if_then(arg1,arg2,arg3); + res4 = SWIG_ConvertPtr(swig_obj[3],SWIG_as_voidptrptr(&arg4), 0, 0); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "reify_x_lt_y" "', argument " "4"" of type '" "void *""'"); + } + reify_x_lt_y(arg1,arg2,arg3,arg4); resultobj = SWIG_Py_Void(); return resultobj; fail: @@ -4928,21 +5473,275 @@ SWIGINTERN PyObject *_wrap_if_then(PyObject *SWIGUNUSEDPARM(self), PyObject *arg } -SWIGINTERN PyObject *_wrap_is_satisfied(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { +SWIGINTERN PyObject *_wrap_reify_x_gt_y(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; void *arg1 = (void *) 0 ; + void *arg2 = (void *) 0 ; + void *arg3 = (void *) 0 ; + void *arg4 = (void *) 0 ; int res1 ; - PyObject *swig_obj[1] ; - int result; + int res2 ; + int res3 ; + int res4 ; + PyObject *swig_obj[4] ; - if (!args) SWIG_fail; - swig_obj[0] = args; + if (!SWIG_Python_UnpackTuple(args, "reify_x_gt_y", 4, 4, swig_obj)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0],SWIG_as_voidptrptr(&arg1), 0, 0); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "is_satisfied" "', argument " "1"" of type '" "void *""'"); + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "reify_x_gt_y" "', argument " "1"" of type '" "void *""'"); } - result = (int)is_satisfied(arg1); - resultobj = SWIG_From_int((int)(result)); + res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "reify_x_gt_y" "', argument " "2"" of type '" "void *""'"); + } + res3 = SWIG_ConvertPtr(swig_obj[2],SWIG_as_voidptrptr(&arg3), 0, 0); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "reify_x_gt_y" "', argument " "3"" of type '" "void *""'"); + } + res4 = SWIG_ConvertPtr(swig_obj[3],SWIG_as_voidptrptr(&arg4), 0, 0); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "reify_x_gt_y" "', argument " "4"" of type '" "void *""'"); + } + reify_x_gt_y(arg1,arg2,arg3,arg4); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_reify_x_le_y(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + void *arg1 = (void *) 0 ; + void *arg2 = (void *) 0 ; + void *arg3 = (void *) 0 ; + void *arg4 = (void *) 0 ; + int res1 ; + int res2 ; + int res3 ; + int res4 ; + PyObject *swig_obj[4] ; + + if (!SWIG_Python_UnpackTuple(args, "reify_x_le_y", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0],SWIG_as_voidptrptr(&arg1), 0, 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "reify_x_le_y" "', argument " "1"" of type '" "void *""'"); + } + res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "reify_x_le_y" "', argument " "2"" of type '" "void *""'"); + } + res3 = SWIG_ConvertPtr(swig_obj[2],SWIG_as_voidptrptr(&arg3), 0, 0); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "reify_x_le_y" "', argument " "3"" of type '" "void *""'"); + } + res4 = SWIG_ConvertPtr(swig_obj[3],SWIG_as_voidptrptr(&arg4), 0, 0); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "reify_x_le_y" "', argument " "4"" of type '" "void *""'"); + } + reify_x_le_y(arg1,arg2,arg3,arg4); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_reify_x_ge_y(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + void *arg1 = (void *) 0 ; + void *arg2 = (void *) 0 ; + void *arg3 = (void *) 0 ; + void *arg4 = (void *) 0 ; + int res1 ; + int res2 ; + int res3 ; + int res4 ; + PyObject *swig_obj[4] ; + + if (!SWIG_Python_UnpackTuple(args, "reify_x_ge_y", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0],SWIG_as_voidptrptr(&arg1), 0, 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "reify_x_ge_y" "', argument " "1"" of type '" "void *""'"); + } + res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "reify_x_ge_y" "', argument " "2"" of type '" "void *""'"); + } + res3 = SWIG_ConvertPtr(swig_obj[2],SWIG_as_voidptrptr(&arg3), 0, 0); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "reify_x_ge_y" "', argument " "3"" of type '" "void *""'"); + } + res4 = SWIG_ConvertPtr(swig_obj[3],SWIG_as_voidptrptr(&arg4), 0, 0); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "reify_x_ge_y" "', argument " "4"" of type '" "void *""'"); + } + reify_x_ge_y(arg1,arg2,arg3,arg4); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_reify_x_lt_yc(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + void *arg1 = (void *) 0 ; + void *arg2 = (void *) 0 ; + void *arg3 = (void *) 0 ; + int arg4 ; + void *arg5 = (void *) 0 ; + int res1 ; + int res2 ; + int res3 ; + int val4 ; + int ecode4 = 0 ; + int res5 ; + PyObject *swig_obj[5] ; + + if (!SWIG_Python_UnpackTuple(args, "reify_x_lt_yc", 5, 5, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0],SWIG_as_voidptrptr(&arg1), 0, 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "reify_x_lt_yc" "', argument " "1"" of type '" "void *""'"); + } + res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "reify_x_lt_yc" "', argument " "2"" of type '" "void *""'"); + } + res3 = SWIG_ConvertPtr(swig_obj[2],SWIG_as_voidptrptr(&arg3), 0, 0); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "reify_x_lt_yc" "', argument " "3"" of type '" "void *""'"); + } + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "reify_x_lt_yc" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + res5 = SWIG_ConvertPtr(swig_obj[4],SWIG_as_voidptrptr(&arg5), 0, 0); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "reify_x_lt_yc" "', argument " "5"" of type '" "void *""'"); + } + reify_x_lt_yc(arg1,arg2,arg3,arg4,arg5); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_reify_x_gt_yc(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + void *arg1 = (void *) 0 ; + void *arg2 = (void *) 0 ; + void *arg3 = (void *) 0 ; + int arg4 ; + void *arg5 = (void *) 0 ; + int res1 ; + int res2 ; + int res3 ; + int val4 ; + int ecode4 = 0 ; + int res5 ; + PyObject *swig_obj[5] ; + + if (!SWIG_Python_UnpackTuple(args, "reify_x_gt_yc", 5, 5, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0],SWIG_as_voidptrptr(&arg1), 0, 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "reify_x_gt_yc" "', argument " "1"" of type '" "void *""'"); + } + res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "reify_x_gt_yc" "', argument " "2"" of type '" "void *""'"); + } + res3 = SWIG_ConvertPtr(swig_obj[2],SWIG_as_voidptrptr(&arg3), 0, 0); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "reify_x_gt_yc" "', argument " "3"" of type '" "void *""'"); + } + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "reify_x_gt_yc" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + res5 = SWIG_ConvertPtr(swig_obj[4],SWIG_as_voidptrptr(&arg5), 0, 0); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "reify_x_gt_yc" "', argument " "5"" of type '" "void *""'"); + } + reify_x_gt_yc(arg1,arg2,arg3,arg4,arg5); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_reify_x_in_s(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + void *arg1 = (void *) 0 ; + void *arg2 = (void *) 0 ; + void *arg3 = (void *) 0 ; + void *arg4 = (void *) 0 ; + int res1 ; + int res2 ; + int res3 ; + int res4 ; + PyObject *swig_obj[4] ; + + if (!SWIG_Python_UnpackTuple(args, "reify_x_in_s", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0],SWIG_as_voidptrptr(&arg1), 0, 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "reify_x_in_s" "', argument " "1"" of type '" "void *""'"); + } + res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "reify_x_in_s" "', argument " "2"" of type '" "void *""'"); + } + res3 = SWIG_ConvertPtr(swig_obj[2],SWIG_as_voidptrptr(&arg3), 0, 0); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "reify_x_in_s" "', argument " "3"" of type '" "void *""'"); + } + res4 = SWIG_ConvertPtr(swig_obj[3],SWIG_as_voidptrptr(&arg4), 0, 0); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "reify_x_in_s" "', argument " "4"" of type '" "void *""'"); + } + reify_x_in_s(arg1,arg2,arg3,arg4); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_reify_x_not_in_s(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + void *arg1 = (void *) 0 ; + void *arg2 = (void *) 0 ; + void *arg3 = (void *) 0 ; + void *arg4 = (void *) 0 ; + int res1 ; + int res2 ; + int res3 ; + int res4 ; + PyObject *swig_obj[4] ; + + if (!SWIG_Python_UnpackTuple(args, "reify_x_not_in_s", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0],SWIG_as_voidptrptr(&arg1), 0, 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "reify_x_not_in_s" "', argument " "1"" of type '" "void *""'"); + } + res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "reify_x_not_in_s" "', argument " "2"" of type '" "void *""'"); + } + res3 = SWIG_ConvertPtr(swig_obj[2],SWIG_as_voidptrptr(&arg3), 0, 0); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "reify_x_not_in_s" "', argument " "3"" of type '" "void *""'"); + } + res4 = SWIG_ConvertPtr(swig_obj[3],SWIG_as_voidptrptr(&arg4), 0, 0); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "reify_x_not_in_s" "', argument " "4"" of type '" "void *""'"); + } + reify_x_not_in_s(arg1,arg2,arg3,arg4); + resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; @@ -14458,8 +15257,29 @@ static PyMethodDef SwigMethods[] = { { "reify_with", _wrap_reify_with, METH_VARARGS, NULL}, { "implies", _wrap_implies, METH_VARARGS, NULL}, { "implied_by", _wrap_implied_by, METH_VARARGS, NULL}, - { "if_then", _wrap_if_then, METH_VARARGS, NULL}, { "is_satisfied", _wrap_is_satisfied, METH_O, NULL}, + { "if_then_else", _wrap_if_then_else, METH_VARARGS, NULL}, + { "if_then_else_bool", _wrap_if_then_else_bool, METH_VARARGS, NULL}, + { "if_then", _wrap_if_then, METH_VARARGS, NULL}, + { "if_then_bool", _wrap_if_then_bool, METH_VARARGS, NULL}, + { "if_only_if", _wrap_if_only_if, METH_VARARGS, NULL}, + { "reification", _wrap_reification, METH_VARARGS, NULL}, + { "reify_x_eq_c", _wrap_reify_x_eq_c, METH_VARARGS, NULL}, + { "reify_x_ne_c", _wrap_reify_x_ne_c, METH_VARARGS, NULL}, + { "reify_x_eq_y", _wrap_reify_x_eq_y, METH_VARARGS, NULL}, + { "reify_x_ne_y", _wrap_reify_x_ne_y, METH_VARARGS, NULL}, + { "reify_x_eq_yc", _wrap_reify_x_eq_yc, METH_VARARGS, NULL}, + { "reify_x_ne_yc", _wrap_reify_x_ne_yc, METH_VARARGS, NULL}, + { "reify_x_lt_c", _wrap_reify_x_lt_c, METH_VARARGS, NULL}, + { "reify_x_gt_c", _wrap_reify_x_gt_c, METH_VARARGS, NULL}, + { "reify_x_lt_y", _wrap_reify_x_lt_y, METH_VARARGS, NULL}, + { "reify_x_gt_y", _wrap_reify_x_gt_y, METH_VARARGS, NULL}, + { "reify_x_le_y", _wrap_reify_x_le_y, METH_VARARGS, NULL}, + { "reify_x_ge_y", _wrap_reify_x_ge_y, METH_VARARGS, NULL}, + { "reify_x_lt_yc", _wrap_reify_x_lt_yc, METH_VARARGS, NULL}, + { "reify_x_gt_yc", _wrap_reify_x_gt_yc, METH_VARARGS, NULL}, + { "reify_x_in_s", _wrap_reify_x_in_s, METH_VARARGS, NULL}, + { "reify_x_not_in_s", _wrap_reify_x_not_in_s, METH_VARARGS, NULL}, { "arithm_iv_cst", _wrap_arithm_iv_cst, METH_VARARGS, NULL}, { "arithm_iv_iv", _wrap_arithm_iv_iv, METH_VARARGS, NULL}, { "arithm_iv_iv_cst", _wrap_arithm_iv_iv_cst, METH_VARARGS, NULL}, diff --git a/pychoco/constraints/constraint.py b/pychoco/constraints/constraint.py index 9fcfcf1..de190ce 100644 --- a/pychoco/constraints/constraint.py +++ b/pychoco/constraints/constraint.py @@ -68,16 +68,16 @@ def reify_with(self, boolvar): @abstractmethod def implies(self, boolvar): """ - Encapsulate this constraint in an implication relationship. - The truth value of this constraints implies the truth value of te boolvar. + Encapsulate this constraint in an implication relationship. + The truth value of this constraints implies the truth value of te boolvar. """ backend.implies(self.handle, boolvar.handle) @abstractmethod def implied_by(self, boolvar): """ - Encapsulate this constraint in an implication relationship. - Represents half-reification of the constraint. + Encapsulate this constraint in an implication relationship. + Represents half-reification of the constraint. """ backend.implied_by(self.handle, boolvar.handle) diff --git a/pychoco/constraints/reification_factory.py b/pychoco/constraints/reification_factory.py index 8192ea9..8cadeee 100644 --- a/pychoco/constraints/reification_factory.py +++ b/pychoco/constraints/reification_factory.py @@ -1,12 +1,17 @@ from abc import ABC, abstractmethod +from typing import Union, List +from pychoco._utils import make_int_array from pychoco.constraints.constraint import Constraint from pychoco import backend +from pychoco.variables.boolvar import BoolVar +from pychoco.variables.intvar import IntVar + class ReificationFactory(ABC): """ - Reification of constraints + Reification of constraints """ @property @@ -14,11 +19,187 @@ class ReificationFactory(ABC): def handle(self): pass + def if_then_else(self, if_constraint_or_boolvar: Union[Constraint, BoolVar], then_constraint: Constraint, + else_constraint: Constraint): + """ + Posts a constraint ensuring that if `if_constraint_or_boolvar`is satisfied (or true), then `then_constraint` + must be satisfied as well. Otherwise, `else_constraint`must be satisfied. + + :param if_constraint_or_boolvar: A Constraint or a BoolVar. + :param then_constraint: A Constraint. + :param else_constraint: A Constraint. + """ + if isinstance(if_constraint_or_boolvar, Constraint): + backend.if_then_else(self.handle, if_constraint_or_boolvar.handle, then_constraint.handle, else_constraint.handle) + else: + backend.if_then_else_bool(self.handle, if_constraint_or_boolvar.handle, then_constraint.handle, else_constraint.handle) + + + def if_then(self, if_constraint_or_boolvar: Union[Constraint, BoolVar], then_constraint: Constraint): + """ + Creates an if-then constraint: if_constraint -> then_constraint. + + :param if_constraint_or_boolvar: A Constraint or a BoolVar. + :param then_constraint: A Constraint. + """ + if isinstance(if_constraint_or_boolvar, Constraint): + backend.if_then(self.handle, if_constraint_or_boolvar.handle, then_constraint.handle) + else: + backend.if_then_bool(self.handle, if_constraint_or_boolvar.handle, then_constraint.handle) + + def if_only_if(self, constraint1_or_boolvar: Union[Constraint, BoolVar], constraint2: Constraint): + """ + Posts an equivalence constraint stating that: + `constraint1_or_boolvar` is satisfied (or true) <=> `constraint2` is satisfied. + + :param constraint1_or_boolvar: A Constraint or a BoolVar. + :param constraint2: A Constraint. + """ + if isinstance(constraint1_or_boolvar, Constraint): + backend.if_only_if(self.handle, constraint1_or_boolvar.handle, constraint2.handle) + else: + backend.reification(self.handle, constraint1_or_boolvar.handle, constraint2.handle) + + def reify_x_eq_y(self, x: IntVar, y: Union[IntVar, int], b: BoolVar): + """ + Posts a constraint that expresses: (x = y) <=> (b = true). + + :param x: An IntVar. + :param y: An IntVar or an int. + :param b: A BoolVar. + """ + if isinstance(y, IntVar): + backend.reify_x_eq_y(self.handle, x.handle, y.handle, b.handle) + else: + backend.reify_x_eq_c(self.handle, x.handle, y, b.handle) + + def reify_x_ne_y(self, x: IntVar, y: Union[IntVar, int], b: BoolVar): + """ + Posts a constraint that expresses: (x != y) <=> (b is true). + + :param x: An IntVar. + :param y: An IntVar or an int. + :param b: A BoolVar. + """ + if isinstance(y, IntVar): + backend.reify_x_ne_y(self.handle, x.handle, y.handle, b.handle) + else: + backend.reify_x_ne_c(self.handle, x.handle, y, b.handle) + + def reify_x_eq_yc(self, x: IntVar, y: IntVar, c: int, b: BoolVar): + """ + Posts a constraint that expresses : (x = y + c) <=> (b is true). + + :param x : An IntVar. + :param y: An IntVar. + :param c: An int. + :param b: A BoolVar. + """ + backend.reify_x_eq_yc(self.handle, x.handle, y.handle, c, b.handle) + + def reify_x_ne_yc(self, x: IntVar, y: IntVar, c: int, b: BoolVar): + """ + Posts a constraint that expresses : (x != y + c) <=> (b is true). + + :param x : An IntVar. + :param y: An IntVar. + :param c: An int. + :param b: A BoolVar. + """ + backend.reify_x_ne_yc(self.handle, x.handle, y.handle, c, b.handle) + + def reify_x_lt_y(self, x: IntVar, y: Union[IntVar, int], b: BoolVar): + """ + Posts a constraint that expresses: (x < y) <=> (b = true). + + :param x: An IntVar. + :param y: An IntVar or an int. + :param b: A BoolVar. + """ + if isinstance(y, IntVar): + backend.reify_x_lt_y(self.handle, x.handle, y.handle, b.handle) + else: + backend.reify_x_lt_c(self.handle, x.handle, y, b.handle) + + def reify_x_gt_y(self, x: IntVar, y: Union[IntVar, int], b: BoolVar): + """ + Posts a constraint that expresses: (x > y) <=> (b = true). + + :param x: An IntVar. + :param y: An IntVar or an int. + :param b: A BoolVar. + """ + if isinstance(y, IntVar): + backend.reify_x_gt_y(self.handle, x.handle, y.handle, b.handle) + else: + backend.reify_x_gt_c(self.handle, x.handle, y, b.handle) - def if_then(self, ifcons: Constraint, thencons: Constraint): + def reify_x_le_y(self, x: IntVar, y: Union[IntVar, int], b: BoolVar): """ - Creates an if-then constraint: ifcons -> thencons - :param ifcons: a Constraint - :param thencons: a Constraint + Posts a constraint that expresses: (x <= y) <=> (b = true). + + :param x: An IntVar. + :param y: An IntVar or an int. + :param b: A BoolVar. + """ + if isinstance(y, IntVar): + backend.reify_x_le_y(self.handle, x.handle, y.handle, b.handle) + else: + backend.reify_x_lt_c(self.handle, x.handle, y + 1, b.handle) + + def reify_x_ge_y(self, x: IntVar, y: Union[IntVar, int], b: BoolVar): + """ + Posts a constraint that expresses: (x >= y) <=> (b = true). + + :param x: An IntVar. + :param y: An IntVar or an int. + :param b: A BoolVar. + """ + if isinstance(y, IntVar): + backend.reify_x_ge_y(self.handle, x.handle, y.handle, b.handle) + else: + backend.reify_x_gt_c(self.handle, x.handle, y - 1, b.handle) + + def reify_x_lt_yc(self, x: IntVar, y: IntVar, c: int, b: BoolVar): + """ + Posts a constraint that expresses : (x < y + c) <=> b. + + :param x: An IntVar. + :param y: An IntVar. + :param c: An int. + :param b: A BoolVar. + """ + backend.reify_x_lt_yc(self.handle, x.handle, y.handle, c, b.handle) + + def reify_x_gt_yc(self, x: IntVar, y: IntVar, c: int, b: BoolVar): + """ + Posts a constraint that expresses : (x > y + c) <=> b. + + :param x: An IntVar. + :param y: An IntVar. + :param c: An int. + :param b: A BoolVar. + """ + backend.reify_x_gt_yc(self.handle, x.handle, y.handle, c, b.handle) + + def reify_x_in_s(self, x: IntVar, s: List[int], b: BoolVar): + """ + Posts a constraint that expresses : (x in s) <=> B. + + :param x: An IntVar. + :param s: A list of ints. + :param b: A BoolVar. + """ + shandle = make_int_array(s) + backend.reify_x_in_s(self.handle, x.handle, shandle, b.handle) + + def reify_x_not_in_s(self, x: IntVar, s: List[int], b: BoolVar): + """ + Posts a constraint that expresses : (x not in s) <=> B. + + :param x: An IntVar. + :param s: A list of ints. + :param b: A BoolVar. """ - return backend.if_then(self.handle, ifcons.handle, thencons.handle) \ No newline at end of file + shandle = make_int_array(s) + backend.reify_x_not_in_s(self.handle, x.handle, shandle, b.handle) diff --git a/setup.py b/setup.py index e09c1bf..bf606f2 100644 --- a/setup.py +++ b/setup.py @@ -85,7 +85,7 @@ def run(self): 'build_ext': CustomBuildExt, 'build': CustomBuild, }, - version='0.1.2', + version='0.2.0', author="Dimitri Justeau-Allaire, Charles Prud'homme", author_email="dimitri.justeau@gmail.com, charles.prudhomme@imt-atlantique.fr", description="Python bindings to the Choco Constraint Programming solver", diff --git a/tests/reification/test_ifthen.py b/tests/reification/test_ifthen.py deleted file mode 100644 index 16389d0..0000000 --- a/tests/reification/test_ifthen.py +++ /dev/null @@ -1,53 +0,0 @@ -import unittest - -from pychoco.model import Model - - -class TestIfThen(unittest.TestCase): - - def testIfThen1(self): - m = Model() - - x = m.intvar(0,10) - y = m.intvar(0,100) - - m.if_then(m.arithm(x, "<", 10), - m.arithm(y, ">", 42)) - - solutions = m.get_solver().find_all_solutions() - for s in solutions: - if_cond = s.get_int_val(x) < 10 - then_cond = s.get_int_val(y) > 42 - self.assertTrue(~if_cond or then_cond) - - - def testImplies(self): - m = Model() - - x = m.intvar(0,10) - b = m.boolvar() - - cons = m.arithm(x, "<", 10) - cons.implies(b) - - solutions = m.get_solver().find_all_solutions() - for s in solutions: - if_cond = s.get_int_val(x) < 10 - then_cond = bool(s.get_int_val(b)) - self.assertTrue(~if_cond or then_cond) - - - def testImpliedBy(self): - m = Model() - - x = m.intvar(0, 10) - b = m.boolvar() - - cons = m.arithm(x, "<", 10) - cons.implied_by(b) - - solutions = m.get_solver().find_all_solutions() - for s in solutions: - if_cond = bool(s.get_int_val(b)) - then_cond = s.get_int_val(x) < 10 - self.assertTrue(~if_cond or then_cond) \ No newline at end of file diff --git a/tests/reification/test_reification_constraints.py b/tests/reification/test_reification_constraints.py new file mode 100644 index 0000000..4596f29 --- /dev/null +++ b/tests/reification/test_reification_constraints.py @@ -0,0 +1,294 @@ +import unittest + +from pychoco.model import Model + + +class TestIfThen(unittest.TestCase): + + def testIfThen1(self): + m = Model() + + x = m.intvar(0,10) + y = m.intvar(0,100) + + m.if_then(m.arithm(x, "<", 10), + m.arithm(y, ">", 42)) + + solutions = m.get_solver().find_all_solutions() + for s in solutions: + if_cond = s.get_int_val(x) < 10 + then_cond = s.get_int_val(y) > 42 + self.assertTrue(~if_cond or then_cond) + + def testIfThenBool(self): + m = Model() + + y = m.intvar(0,100) + b = m.boolvar() + + m.if_then(b, m.arithm(y, ">", 42)) + + solutions = m.get_solver().find_all_solutions() + for s in solutions: + if_cond = s.get_int_val(b) == 1 + then_cond = s.get_int_val(y) > 42 + self.assertTrue(~if_cond or then_cond) + + def testImplies(self): + m = Model() + + x = m.intvar(0,10) + b = m.boolvar() + + cons = m.arithm(x, "<", 10) + cons.implies(b) + + solutions = m.get_solver().find_all_solutions() + for s in solutions: + if_cond = s.get_int_val(x) < 10 + then_cond = bool(s.get_int_val(b)) + self.assertTrue(~if_cond or then_cond) + + + def testImpliedBy(self): + m = Model() + + x = m.intvar(0, 10) + b = m.boolvar() + + cons = m.arithm(x, "<", 10) + cons.implied_by(b) + + solutions = m.get_solver().find_all_solutions() + for s in solutions: + if_cond = bool(s.get_int_val(b)) + then_cond = s.get_int_val(x) < 10 + self.assertTrue(~if_cond or then_cond) + + def test_if_then_else(self): + m = Model() + x = m.intvar(0, 10) + y = m.intvar(0, 10) + cstr1 = m.arithm(x, ">", y) + cstr2 = m.arithm(y, ">=", 5) + cstr3 = m.arithm(y, "<=", 3) + m.if_then_else(cstr1, cstr2, cstr3) + sols = m.get_solver().find_all_solutions() + for s in sols: + if s.get_int_val(x) > s.get_int_val(y): + self.assertTrue(s.get_int_val(y) >= 5) + else: + self.assertTrue(s.get_int_val(y) <= 3) + + def test_if_then_else_bool(self): + m = Model() + x = m.intvar(0, 10) + y = m.intvar(0, 10) + b = m.boolvar() + cstr2 = m.arithm(y, ">=", 5) + cstr3 = m.arithm(y, "<=", 3) + m.if_then_else(b, cstr2, cstr3) + sols = m.get_solver().find_all_solutions() + for s in sols: + if s.get_int_val(b) == 1: + self.assertTrue(s.get_int_val(y) >= 5) + else: + self.assertTrue(s.get_int_val(y) <= 3) + + def test_if_only_if(self): + m = Model() + x = m.intvar(0, 10) + y = m.intvar(0, 10) + cstr1 = m.arithm(x, ">", y) + cstr2 = m.arithm(y, ">=", 5) + m.if_only_if(cstr1, cstr2) + sols = m.get_solver().find_all_solutions() + for s in sols: + b1 = s.get_int_val(x) > s.get_int_val(y) + b2 = s.get_int_val(y) >= 5 + self.assertEqual(b1, b2) + + def test_if_only_if_bool(self): + m = Model() + x = m.intvar(0, 10) + y = m.intvar(0, 10) + cstr1 = m.arithm(x, ">", y) + b = m.boolvar() + m.if_only_if(b, cstr1) + sols = m.get_solver().find_all_solutions() + for s in sols: + b1 = s.get_int_val(x) > s.get_int_val(y) + b2 = s.get_int_val(b) == 1 + self.assertEqual(b1, b2) + + def test_reify_x_eq_y(self): + m = Model() + x = m.intvar(0, 10) + y = m.intvar(0, 10) + b = m.boolvar() + m.reify_x_eq_y(x, y, b) + sols = m.get_solver().find_all_solutions() + for s in sols: + b1 = s.get_int_val(x) == s.get_int_val(y) + b2 = s.get_int_val(b) == 1 + self.assertEqual(b1, b2) + + def test_reify_x_eq_c(self): + m = Model() + x = m.intvar(0, 10) + y = 5 + b = m.boolvar() + m.reify_x_eq_y(x, y, b) + sols = m.get_solver().find_all_solutions() + for s in sols: + b1 = s.get_int_val(x) == y + b2 = s.get_int_val(b) == 1 + self.assertEqual(b1, b2) + + def test_reify_x_ne_y(self): + m = Model() + x = m.intvar(0, 10) + y = m.intvar(0, 10) + b = m.boolvar() + m.reify_x_ne_y(x, y, b) + sols = m.get_solver().find_all_solutions() + for s in sols: + b1 = s.get_int_val(x) != s.get_int_val(y) + b2 = s.get_int_val(b) == 1 + self.assertEqual(b1, b2) + + def test_reify_x_ne_c(self): + m = Model() + x = m.intvar(0, 10) + y = 5 + b = m.boolvar() + m.reify_x_ne_y(x, y, b) + sols = m.get_solver().find_all_solutions() + for s in sols: + b1 = s.get_int_val(x) != y + b2 = s.get_int_val(b) == 1 + self.assertEqual(b1, b2) + + def test_reify_x_eq_yc(self): + m = Model() + x = m.intvar(0, 10) + y = m.intvar(0, 10) + c = 2 + b = m.boolvar() + m.reify_x_eq_yc(x, y, c, b) + sols = m.get_solver().find_all_solutions() + for s in sols: + b1 = s.get_int_val(x) == s.get_int_val(y) + c + b2 = s.get_int_val(b) == 1 + self.assertEqual(b1, b2) + + def test_reify_x_ne_yc(self): + m = Model() + x = m.intvar(0, 10) + y = m.intvar(0, 10) + c = 2 + b = m.boolvar() + m.reify_x_ne_yc(x, y, c, b) + sols = m.get_solver().find_all_solutions() + for s in sols: + b1 = s.get_int_val(x) != s.get_int_val(y) + c + b2 = s.get_int_val(b) == 1 + self.assertEqual(b1, b2) + + def test_reify_x_lt_y(self): + m = Model() + x = m.intvar(0, 10) + y = m.intvar(0, 10) + b = m.boolvar() + m.reify_x_lt_y(x, y, b) + sols = m.get_solver().find_all_solutions() + for s in sols: + b1 = s.get_int_val(x) < s.get_int_val(y) + b2 = s.get_int_val(b) == 1 + self.assertEqual(b1, b2) + + def test_reify_x_gt_y(self): + m = Model() + x = m.intvar(0, 10) + y = m.intvar(0, 10) + b = m.boolvar() + m.reify_x_gt_y(x, y, b) + sols = m.get_solver().find_all_solutions() + for s in sols: + b1 = s.get_int_val(x) > s.get_int_val(y) + b2 = s.get_int_val(b) == 1 + self.assertEqual(b1, b2) + + def test_reify_x_le_y(self): + m = Model() + x = m.intvar(0, 10) + y = m.intvar(0, 10) + b = m.boolvar() + m.reify_x_le_y(x, y, b) + sols = m.get_solver().find_all_solutions() + for s in sols: + b1 = s.get_int_val(x) <= s.get_int_val(y) + b2 = s.get_int_val(b) == 1 + self.assertEqual(b1, b2) + + def test_reify_x_ge_y(self): + m = Model() + x = m.intvar(0, 10) + y = m.intvar(0, 10) + b = m.boolvar() + m.reify_x_ge_y(x, y, b) + sols = m.get_solver().find_all_solutions() + for s in sols: + b1 = s.get_int_val(x) >= s.get_int_val(y) + b2 = s.get_int_val(b) == 1 + self.assertEqual(b1, b2) + + def test_reify_x_lt_yc(self): + m = Model() + x = m.intvar(0, 10) + y = m.intvar(0, 10) + c = 2 + b = m.boolvar() + m.reify_x_lt_yc(x, y, c, b) + sols = m.get_solver().find_all_solutions() + for s in sols: + b1 = s.get_int_val(x) < s.get_int_val(y) + c + b2 = s.get_int_val(b) == 1 + self.assertEqual(b1, b2) + + def test_reify_x_gt_yc(self): + m = Model() + x = m.intvar(0, 10) + y = m.intvar(0, 10) + c = 2 + b = m.boolvar() + m.reify_x_gt_yc(x, y, c, b) + sols = m.get_solver().find_all_solutions() + for s in sols: + b1 = s.get_int_val(x) > s.get_int_val(y) + c + b2 = s.get_int_val(b) == 1 + self.assertEqual(b1, b2) + + def test_reify_x_in_s(self): + m = Model() + x = m.intvar(0, 10) + s = [1, 3, 5, 7] + b = m.boolvar() + m.reify_x_in_s(x, s, b) + sols = m.get_solver().find_all_solutions() + for sol in sols: + b1 = sol.get_int_val(x) in s + b2 = sol.get_int_val(b) == 1 + self.assertEqual(b1, b2) + + def test_reify_x_not_in_s(self): + m = Model() + x = m.intvar(0, 10) + s = [1, 3, 5, 7] + b = m.boolvar() + m.reify_x_not_in_s(x, s, b) + sols = m.get_solver().find_all_solutions() + for sol in sols: + b1 = sol.get_int_val(x) not in s + b2 = sol.get_int_val(b) == 1 + self.assertEqual(b1, b2) \ No newline at end of file