uint size=getSizeVectorBoolean(constraints);
for(uint i=0;i<size;i++) {
Boolean *constraint=getVectorBoolean(constraints, i);
- encodeConstraintSATEncoder(This, constraint);
+ Constraint* c= encodeConstraintSATEncoder(This, constraint);
+ printConstraint(c);
}
}
case L_OR:
return allocArrayConstraint(OR, getSizeArrayBoolean(&constraint->inputs), array);
case L_NOT:
- ASSERT(constraint->numArray==1);
+ ASSERT( getSizeArrayBoolean(&constraint->inputs)==1);
return negateConstraint(array[0]);
case L_XOR: {
- ASSERT(constraint->numArray==2);
+ ASSERT( getSizeArrayBoolean(&constraint->inputs)==2);
Constraint * nleft=negateConstraint(cloneConstraint(array[0]));
Constraint * nright=negateConstraint(cloneConstraint(array[1]));
return allocConstraint(OR,
allocConstraint(AND, nleft, array[1]));
}
case L_IMPLIES:
- ASSERT(constraint->numArray==2);
+ ASSERT( getSizeArrayBoolean( &constraint->inputs)==2);
return allocConstraint(IMPLIES, array[0], array[1]);
default:
model_print("Unhandled case in encodeLogicSATEncoder %u", constraint->op);
HashTableBoolConst* boolToConsts = boolOrder->order->boolsToConstraints;
OrderPair pair={boolOrder->first, boolOrder->second};
Constraint* constraint = getPairConstraint(This, boolToConsts, & pair);
+ ASSERT(constraint != NULL);
return constraint;
}
Constraint * generateTransOrderConstraintSATEncoder(SATEncoder *This, Constraint *constIJ,Constraint *constJK,Constraint *constIK){
//FIXME: first we should add the the constraint to the satsolver!
+ ASSERT(constIJ!= NULL && constJK != NULL && constIK != NULL);
Constraint *carray[] = {constIJ, constJK, negateConstraint(constIK)};
Constraint * loop1= allocArrayConstraint(OR, 3, carray);
Constraint * carray2[] = {negateConstraint(constIJ), negateConstraint(constJK), constIK};
// FIXME: we can have this implementation for partial order. Basically,
// we compute the transitivity between two order constraints specified by the client! (also can be used
// when client specify sparse constraints for the total order!)
- ASSERT(boolOrder->order->type == PARTIAL);
+ ASSERT(constraint->order->type == PARTIAL);
/*
HashTableBoolConst* boolToConsts = boolOrder->order->boolsToConstraints;
if( containsBoolConst(boolToConsts, boolOrder) ){
if( GETELEMENTTYPE(el) == ELEMFUNCRETURN)
encodeFunctionElementSATEncoder(This, (ElementFunction*) el);
carray[j] = getElementValueConstraint(el, entry->inputs[j]);
+ ASSERT(carray[j]!= NULL);
}
constraints[i]=allocArrayConstraint(AND, inputNum, carray);
}
if( GETELEMENTTYPE(elem2) == ELEMFUNCRETURN)
encodeFunctionElementSATEncoder(This, (ElementFunction*) elem2);
for(uint i=0; i<size; i++){
- carray[i] = allocConstraint(AND, getElementValueConstraint(elem1, commonElements[i]),
- getElementValueConstraint(elem2, commonElements[i]) );
+ Constraint* arg1 = getElementValueConstraint(elem1, commonElements[i]);
+ ASSERT(arg1!=NULL);
+ Constraint* arg2 = getElementValueConstraint(elem2, commonElements[i]);
+ ASSERT(arg2 != NULL);
+ carray[i] = allocConstraint(AND, arg1, arg2);
}
//FIXME: the case when there is no intersection ....
return allocArrayConstraint(OR, size, carray);
Constraint* encodeOperatorElementFunctionSATEncoder(SATEncoder* encoder, ElementFunction* This){
ASSERT(GETFUNCTIONTYPE(This->function) == OPERATORFUNC);
- ASSERT(getSizeArrayElement(&This->inputs)=2 );
+ ASSERT(getSizeArrayElement(&This->inputs)==2 );
ElementEncoding* elem1 = getElementEncoding( getArrayElement(&This->inputs,0) );
ElementEncoding* elem2 = getElementEncoding( getArrayElement(&This->inputs,1) );
Constraint* carray[elem1->encArraySize*elem2->encArraySize];
break; // Ignoring the cases that result of operation doesn't exist in the code.
//FIXME: instead of getElementValueConstraint, it might be useful to have another function
// that doesn't iterate over encodingArray and treats more efficient ...
+ Constraint* and1 = getElementValueConstraint(elem1->element, elem1->encodingArray[i]);
+ ASSERT(and1 != NULL);
+ Constraint* and2 = getElementValueConstraint(elem2->element, elem2->encodingArray[j]);
+ ASSERT(and2 != NULL);
+ Constraint* imply2 = getElementValueConstraint((Element*) This, result);
+ ASSERT(imply2 != NULL);
Constraint* constraint = allocConstraint(IMPLIES,
- allocConstraint(AND, getElementValueConstraint(elem1->element, elem1->encodingArray[i]),
- getElementValueConstraint(elem2->element, elem2->encodingArray[j])) ,
- getElementValueConstraint((Element*) This, result) );
+ allocConstraint(AND, and1, and2) , imply2);
switch( ((FunctionOperator*)This->function)->overflowbehavior ){
case IGNORE:
if(!hasOverFlow){
for(uint j=0; j<inputNum; j++){
Element* el= getArrayElement(elements, j);
carray[j] = getElementValueConstraint(el, entry->inputs[j]);
+ ASSERT(carray[j]!= NULL);
}
- Constraint* row= allocConstraint(IMPLIES, allocArrayConstraint(AND, inputNum, carray),
- getElementValueBinaryIndexConstraint((Element*)This, entry->output));
+ Constraint* output = getElementValueConstraint((Element*)This, entry->output);
+ ASSERT(output!= NULL);
+ Constraint* row= allocConstraint(IMPLIES, allocArrayConstraint(AND, inputNum, carray), output);
constraints[i]=row;
}
Constraint* result = allocArrayConstraint(OR, size, constraints);