op(_op),
replaced(false),
inputs(array, asize) {
+ for (uint i = 0; i < asize; i++) {
+ array[i]->parents.push(this);
+ }
}
BooleanEdge cloneEdge(CSolver *solver, CloneMap *map, BooleanEdge e) {
for (uint i = 0; i < size; i++) {
Boolean *parent = oldb->parents.get(i);
BooleanLogic *logicop = (BooleanLogic *) parent;
-
+ boolMap.remove(parent); //could change parent's hash
+
uint parentsize = logicop->inputs.getSize();
-
for (uint j = 0; j < parentsize; j++) {
- BooleanEdge b = logicop->inputs.get(i);
+ BooleanEdge b = logicop->inputs.get(j);
if (b == oldb) {
- logicop->inputs.set(i, newb);
+ logicop->inputs.set(j, newb);
newb->parents.push(parent);
} else if (b == oldbnegated) {
- logicop->inputs.set(i, newb.negate());
+ logicop->inputs.set(j, newb.negate());
newb->parents.push(parent);
}
}
+ boolMap.put(parent, parent);
}
}
OrderNode *from = currGraph->getOrderNodeFromOrderGraph(orderconstraint->first);
OrderNode *to = currGraph->getOrderNodeFromOrderGraph(orderconstraint->second);
if (from->sccNum != to->sccNum) {
- OrderEdge *edge = currGraph->getOrderEdgeFromOrderGraph(from, to);
- if (edge->polPos) {
- solver->replaceBooleanWithTrue(orderconstraint);
- } else if (edge->polNeg) {
- solver->replaceBooleanWithFalse(orderconstraint);
+ OrderEdge *edge = currGraph->lookupOrderEdgeFromOrderGraph(from, to);
+ if (edge != NULL) {
+ if (edge->polPos) {
+ solver->replaceBooleanWithTrue(orderconstraint);
+ } else if (edge->polNeg) {
+ solver->replaceBooleanWithFalse(orderconstraint);
+ } else {
+ //This case should only be possible if constraint isn't in AST
+ //This can happen, so don't do anything
+ ;
+ }
} else {
- //This case should only be possible if constraint isn't in AST
- ASSERT(0);
+ OrderEdge *invedge = currGraph->lookupOrderEdgeFromOrderGraph(to, from);
+ if (invedge != NULL) {
+ if (invedge->polPos) {
+ solver->replaceBooleanWithFalse(orderconstraint);
+ } else if (edge->polNeg) {
+ //This case shouldn't happen... If we have a partial order,
+ //then we should have our own edge...If we have a total
+ //order, then this edge should be positive...
+ ASSERT(0);
+ } else {
+ //This case should only be possible if constraint isn't in AST
+ //This can happen, so don't do anything
+ ;
+ }
+ }
}
} else {
//Build new order and change constraint's order
Predicate *predicate = solver->createPredicateOperator(SATC_LT, sarray, 2);
Element *parray[] = {elem1, elem2};
BooleanEdge boolean = solver->applyPredicate(predicate, parray, 2);
- solver->addConstraint(boolean);
solver->replaceBooleanWithBoolean(boolOrder, boolean);
}
#include "orderpairresolver.h"
Edge SATEncoder::encodeOrderSATEncoder(BooleanOrder *constraint) {
- //This is pairwised encoding ...
- constraint->order->setOrderResolver(new OrderPairResolver(solver, constraint->order));
switch ( constraint->order->type) {
case SATC_PARTIAL:
return encodePartialOrderSATEncoder(constraint);
Edge SATEncoder::encodeTotalOrderSATEncoder(BooleanOrder *boolOrder) {
ASSERT(boolOrder->order->type == SATC_TOTAL);
if (boolOrder->order->orderPairTable == NULL) {
+ //This is pairwised encoding ...
+ boolOrder->order->setOrderResolver(new OrderPairResolver(solver, boolOrder->order));
boolOrder->order->initializeOrderHashtable();
bool doOptOrderStructure = GETVARTUNABLE(solver->getTuner(), boolOrder->order->type, OPTIMIZEORDERSTRUCTURE, &onoff);
if (doOptOrderStructure) {