Merge branch 'hamed' of ssh://plrg.eecs.uci.edu/home/git/constraint_compiler into...
authorbdemsky <bdemsky@uci.edu>
Fri, 17 Aug 2018 21:42:54 +0000 (14:42 -0700)
committerbdemsky <bdemsky@uci.edu>
Fri, 17 Aug 2018 21:42:54 +0000 (14:42 -0700)
.gitignore
deploy-cs.sh [new file with mode: 0755]
src/ASTTransform/elementopt.cc
src/Test/ccsolvertest.c
src/Translator/sattranslator.cc
src/ccsolver.cc
src/ccsolver.h
src/csolver.cc
src/pycsolver.py

index 480418d..64236e1 100644 (file)
@@ -1,6 +1,6 @@
 #Ignoring netbeans configs
 nbproject/
-sat_solver
+sat_solver*
 setup.sh
 
 #Ignoring binary files
diff --git a/deploy-cs.sh b/deploy-cs.sh
new file mode 100755 (executable)
index 0000000..3e3dcc7
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+#Terminate the script if even one command fails
+set -e
+
+BASE=../
+SERVERS="dc-8.calit2.uci.edu dc-9.calit2.uci.edu dc-10.calit2.uci.edu dc-11.calit2.uci.edu"
+REMOTEDIR="/scratch/hamed/"
+INFILE="constraint_compiler/"
+SRC="constraint_compiler/src/"
+OUTFILE=csolver.tar.gz
+USER=hamed
+
+cd $BASE
+
+rm -f $OUTFILE
+tar -czvf $OUTFILE $INFILE
+
+for SERVER in $SERVERS; do
+       scp $OUTFILE "$USER@$SERVER:$REMOTEDIR"
+       ssh $USER@$SERVER "cd $REMOTEDIR; sudo rm -r $SRC; tar -xzvf $OUTFILE; cd $SRC; make clean; ./setup.sh"
+done
index d6dec3d..3f1f892 100755 (executable)
@@ -98,7 +98,7 @@ void ElementOpt::handlePredicateInequality(BooleanPredicate *pred, ElementSet *v
        case SATC_LT: {
                for(uint i=0; i<size; i++) {
                        uint64_t val = s->getElement(i);
-                       if (val >= cvalue)
+                       if (val < cvalue)
                                elemArray[count++] = val;
                }
                break;
@@ -106,7 +106,7 @@ void ElementOpt::handlePredicateInequality(BooleanPredicate *pred, ElementSet *v
        case SATC_GT: {
                for(uint i=0; i<size; i++) {
                        uint64_t val = s->getElement(i);
-                       if (val <= cvalue)
+                       if (val > cvalue)
                                elemArray[count++] = val;
                }
                break;
@@ -114,7 +114,7 @@ void ElementOpt::handlePredicateInequality(BooleanPredicate *pred, ElementSet *v
        case SATC_LTE: {
                for(uint i=0; i<size; i++) {
                        uint64_t val = s->getElement(i);
-                       if (val > cvalue)
+                       if (val <= cvalue)
                                elemArray[count++] = val;
                }
                break;
@@ -122,7 +122,7 @@ void ElementOpt::handlePredicateInequality(BooleanPredicate *pred, ElementSet *v
        case SATC_GTE: {
                for(uint i=0; i<size; i++) {
                        uint64_t val = s->getElement(i);
-                       if (val < cvalue)
+                       if (val >= cvalue)
                                elemArray[count++] = val;
                }
                break;
index ab2c1ab..41f2f2d 100644 (file)
@@ -20,5 +20,6 @@ int main (int num, char** args){
         else
                 printf("UNSAT\n");
         deleteCCSolver(solver);
+       return 0;
 }
 
index 1e95596..8e2fcf1 100644 (file)
@@ -52,15 +52,12 @@ uint64_t getElementValueOneHotSATTranslator(CSolver *This, ElementEncoding *elem
 
 uint64_t getElementValueUnarySATTranslator(CSolver *This, ElementEncoding *elemEnc) {
        uint i;
-       bool overflow = true;
        for (i = 0; i < elemEnc->numVars; i++) {
                if (!getValueSolver(This->getSATEncoder()->getCNF()->solver, getEdgeVar( elemEnc->variables[i] )) ) {
-                       overflow = false;
                        break;
                }
        }
-       if(overflow)
-               model_print("WARNING: Element has undefined value!\n");
+
        return elemEnc->encodingArray[i];
 }
 
index 25e1761..1c45480 100644 (file)
@@ -144,3 +144,7 @@ void serialize(void* solver){
 void mustHaveValue(void *solver, void *element){
        CCSOLVER(solver)->mustHaveValue( (Element*) element);
 }
+
+void* clone(void * solver){
+       return CCSOLVER(solver)->clone();
+}
\ No newline at end of file
index f98dbf2..a17bd1c 100644 (file)
@@ -41,6 +41,7 @@ int getOrderConstraintValue(void* solver,void *order, long first, long second);
 void printConstraints(void* solver);
 void serialize(void* solver);
 void mustHaveValue(void *solver, void *element);
+void* clone(void * solver);
 #ifdef __cplusplus
 }
 #endif
index 3eabf2e..44b29bb 100644 (file)
@@ -251,6 +251,7 @@ Element *CSolver::getElementConst(VarType type, uint64_t value) {
 
 
 Element *CSolver::applyFunction(Function *function, Element **array, uint numArrays, BooleanEdge overflowstatus) {
+       ASSERT(numArrays == 2);
        Element *element = new ElementFunction(function,array,numArrays,overflowstatus);
        Element *e = elemMap.get(element);
        if (e == NULL) {
index ba49d77..b0e43a9 100644 (file)
@@ -109,6 +109,8 @@ def loadCSolver():
        csolverlb.getOrderConstraintValue.restype = c_int
        csolverlb.printConstraints.argtypes = [c_void_p]
        csolverlb.printConstraints.restype = None
+        csolverlb.clone.argtypes = [c_void_p]
+       csolverlb.clone.restype = c_void_p
        csolverlb.serialize.argtypes = [c_void_p]
        csolverlb.serialize.restype = None
        return csolverlb