From 3e65b7dbdb78b63c39350090a5c5bb4eec4f4af9 Mon Sep 17 00:00:00 2001 From: Hamed Gorjiara Date: Fri, 14 Jun 2019 15:17:24 -0700 Subject: [PATCH] Adding incremental to Java, C, and python APIs --- src/ccsolver.cc | 8 ++++++++ src/ccsolver.h | 2 ++ src/pycsolver.py | 6 +++++- src/satune_SatuneJavaAPI.cc | 22 ++++++++++++++++++++++ src/satune_SatuneJavaAPI.h | 17 +++++++++++++++++ 5 files changed, 54 insertions(+), 1 deletion(-) diff --git a/src/ccsolver.cc b/src/ccsolver.cc index fa2e342..ca20617 100644 --- a/src/ccsolver.cc +++ b/src/ccsolver.cc @@ -146,10 +146,18 @@ int solve(void *solver) { return CCSOLVER(solver)->solve(); } +int solveIncremental(void *solver) { + return CCSOLVER(solver)->solveIncremental(); +} + long getElementValue(void *solver,void *element) { return (long) CCSOLVER(solver)->getElementValue((Element *)element); } +void freezeElement(void *solver,void *element) { + CCSOLVER(solver)->freezeElement((Element *)element); +} + int getBooleanValue(void *solver, void *boolean) { return CCSOLVER(solver)->getBooleanValue(BooleanEdge((Boolean *) boolean)); } diff --git a/src/ccsolver.h b/src/ccsolver.h index 86d5a46..091303f 100644 --- a/src/ccsolver.h +++ b/src/ccsolver.h @@ -40,7 +40,9 @@ void printConstraint(void *solver,void *constraint); void *createOrder(void *solver,unsigned int type, void *set); void *orderConstraint(void *solver,void *order, long first, long second); int solve(void *solver); +int solveIncremental(void *solver); long getElementValue(void *solver,void *element); +void freezeElement(void *solver,void *element); int getBooleanValue(void *solver,void *boolean); int getOrderConstraintValue(void *solver,void *order, long first, long second); void printConstraints(void *solver); diff --git a/src/pycsolver.py b/src/pycsolver.py index 461a859..905d1d7 100644 --- a/src/pycsolver.py +++ b/src/pycsolver.py @@ -101,10 +101,14 @@ def loadCSolver(): csolverlb.orderConstraint.restype = c_void_p csolverlb.solve.argtypes = [c_void_p] csolverlb.solve.restype = c_int + csolverlb.solveIncremental.argtypes = [c_void_p] + csolverlb.solveIncremental.restype = c_int csolverlb.mustHaveValue.argtypes = [c_void_p, c_void_p] csolverlb.mustHaveValue.restype = c_void_p csolverlb.getElementValue.argtypes = [c_void_p, c_void_p] - csolverlb.getElementValue.restype = c_long + csolverlb.getElementValue.restype = c_void_p + csolverlb.freezeElement.argtypes = [c_void_p, c_void_p] + csolverlb.freezeElement.restype = c_long csolverlb.getBooleanValue.argtypes = [c_void_p, c_void_p] csolverlb.getBooleanValue.restype = c_int csolverlb.getOrderConstraintValue.argtypes = [c_void_p, c_void_p, c_long, c_long] diff --git a/src/satune_SatuneJavaAPI.cc b/src/satune_SatuneJavaAPI.cc index 21cd504..d1397ee 100644 --- a/src/satune_SatuneJavaAPI.cc +++ b/src/satune_SatuneJavaAPI.cc @@ -391,6 +391,17 @@ JNIEXPORT jint JNICALL Java_satune_SatuneJavaAPI_solve return (jint) solve((void *)solver); } +/* + * Class: SatuneJavaAPI + * Method: solveIncremental + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_satune_SatuneJavaAPI_solveIncremental + (JNIEnv *env, jobject obj, jlong solver) +{ + return (jint) solveIncremental((void *)solver); +} + /* * Class: SatuneJavaAPI * Method: getElementValue @@ -402,6 +413,17 @@ JNIEXPORT jlong JNICALL Java_satune_SatuneJavaAPI_getElementValue return (jlong) getElementValue((void *)solver,(void *)element); } +/* + * Class: SatuneJavaAPI + * Method: freezeElement + * Signature: (JJ)J + */ +JNIEXPORT void JNICALL Java_satune_SatuneJavaAPI_freezeElement + (JNIEnv *env, jobject obj, jlong solver, jlong element) +{ + freezeElement((void *)solver,(void *)element); +} + /* * Class: SatuneJavaAPI * Method: getBooleanValue diff --git a/src/satune_SatuneJavaAPI.h b/src/satune_SatuneJavaAPI.h index 68703bc..7b301f9 100644 --- a/src/satune_SatuneJavaAPI.h +++ b/src/satune_SatuneJavaAPI.h @@ -280,6 +280,14 @@ JNIEXPORT jlong JNICALL Java_satune_SatuneJavaAPI_orderConstraint JNIEXPORT jint JNICALL Java_satune_SatuneJavaAPI_solve (JNIEnv *, jobject, jlong); +/* + * Class: satune_SatuneJavaAPI + * Method: solveIncremental + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_satune_SatuneJavaAPI_solveIncremental + (JNIEnv *, jobject, jlong); + /* * Class: satune_SatuneJavaAPI * Method: getElementValue @@ -288,6 +296,15 @@ JNIEXPORT jint JNICALL Java_satune_SatuneJavaAPI_solve JNIEXPORT jlong JNICALL Java_satune_SatuneJavaAPI_getElementValue (JNIEnv *, jobject, jlong, jlong); + +/* + * Class: satune_SatuneJavaAPI + * Method: getElementValue + * Signature: (JJ)J + */ +JNIEXPORT void JNICALL Java_satune_SatuneJavaAPI_freezeElement + (JNIEnv *, jobject, jlong, jlong); + /* * Class: satune_SatuneJavaAPI * Method: getBooleanValue -- 2.34.1