This->order=order;
This->first=first;
This->second=second;
- pushVectorBoolean(&order->constraints, &This->base);
+ pushVectorBooleanOrder(&order->constraints, This);
initDefVectorBoolean(GETBOOLEANPARENTS(This));
return & This -> base;
}
Order* allocOrder(OrderType type, Set * set){
Order* This = (Order*)ourmalloc(sizeof(Order));
This->set=set;
- initDefVectorBoolean(& This->constraints);
+ initDefVectorBooleanOrder(& This->constraints);
This->type=type;
initOrderEncoding(& This->order, This);
This->orderPairTable = NULL;
}
void addOrderConstraint(Order* This, BooleanOrder* constraint){
- pushVectorBoolean( &This->constraints, (Boolean*) constraint);
+ pushVectorBooleanOrder( &This->constraints, constraint);
}
void setOrderEncodingType(Order* This, OrderEncodingType type){
}
void deleteOrder(Order* This){
- deleteVectorArrayBoolean(& This->constraints);
+ deleteVectorArrayBooleanOrder(& This->constraints);
deleteOrderEncoding(& This->order);
if(This->orderPairTable != NULL) {
resetAndDeleteHashTableOrderPair(This->orderPairTable);
OrderType type;
Set * set;
HashTableOrderPair * orderPairTable;
- VectorBoolean constraints;
+ VectorBooleanOrder constraints;
OrderEncoding order;
};
VectorImpl(Table, Table *, 4);
VectorImpl(Set, Set *, 4);
VectorImpl(Boolean, Boolean *, 4);
+VectorImpl(BooleanOrder, BooleanOrder *, 4);
VectorImpl(Function, Function *, 4);
VectorImpl(Predicate, Predicate *, 4);
VectorImpl(Element, Element *, 4);
VectorDef(Table, Table *);
VectorDef(Set, Set *);
VectorDef(Boolean, Boolean *);
+VectorDef(BooleanOrder, BooleanOrder *);
VectorDef(Function, Function *);
VectorDef(Predicate, Predicate *);
VectorDef(Element, Element *);
OrderGraph* buildOrderGraph(Order *order) {
OrderGraph* orderGraph = allocOrderGraph(order);
- uint constrSize = getSizeVectorBoolean(&order->constraints);
+ uint constrSize = getSizeVectorBooleanOrder(&order->constraints);
for(uint j=0; j<constrSize; j++){
- addOrderConstraintToOrderGraph(orderGraph, getVectorBoolean(&order->constraints, j));
+ addOrderConstraintToOrderGraph(orderGraph, getVectorBooleanOrder(&order->constraints, j));
}
return orderGraph;
}
OrderNode* node = nextOrderNode(iterator);
if(node->status == NOTVISITED){
node->status = VISITED;
- DFSNodeVisit(node, finishNodes, false);
+ DFSNodeVisit(node, finishNodes, false, 0);
node->status = FINISHED;
pushVectorOrderNode(finishNodes, node);
}
void DFSReverse(OrderGraph* graph, VectorOrderNode* finishNodes) {
uint size = getSizeVectorOrderNode(finishNodes);
+ uint sccNum=1;
for(int i=size-1; i>=0; i--){
OrderNode* node = getVectorOrderNode(finishNodes, i);
if(node->status == NOTVISITED){
node->status = VISITED;
- DFSNodeVisit(node, NULL, true);
+ DFSNodeVisit(node, NULL, true, sccNum);
+ node->sccNum = sccNum;
node->status = FINISHED;
- pushVectorOrderNode(&graph->scc, node);
+ sccNum++;
}
}
}
-void DFSNodeVisit(OrderNode* node, VectorOrderNode* finishNodes, bool isReverse) {
+void DFSNodeVisit(OrderNode* node, VectorOrderNode* finishNodes, bool isReverse, uint sccNum) {
HSIteratorOrderEdge* iterator = isReverse?iteratorOrderEdge(node->inEdges):iteratorOrderEdge(node->outEdges);
while(hasNextOrderEdge(iterator)){
OrderEdge* edge = nextOrderEdge(iterator);
OrderNode* child = isReverse? edge->source: edge->sink;
- if(child->status == NOTVISITED){
+ if(child->status == NOTVISITED) {
child->status = VISITED;
- DFSNodeVisit(child, finishNodes, isReverse);
+ DFSNodeVisit(child, finishNodes, isReverse, sccNum);
child->status = FINISHED;
if(!isReverse)
pushVectorOrderNode(finishNodes, child);
+ else
+ child->sccNum = sccNum;
}
}
deleteIterOrderEdge(iterator);
deleteIterOrderEdge(iterator);
}
+void decomposeOrder(Order *order, OrderGraph *graph) {
+ uint size=getSizeVectorBooleanOrder(&order->constraints);
+ for(uint i=0;i<size;i++) {
+ }
+}
+
void orderAnalysis(CSolver* This) {
uint size = getSizeVectorOrder(This->allOrders);
for(uint i=0; i<size; i++){
localMustAnalysisTotal(graph);
}
- //This analysis is completely optional
+ //This optimization is completely optional
removeMustBeTrueNodes(graph);
+ //This is needed for splitorder
computeStronglyConnectedComponentGraph(graph);
+
+ decomposeOrder(order, graph);
+
deleteOrderGraph(graph);
}
}
void computeStronglyConnectedComponentGraph(OrderGraph* graph);
void orderAnalysis(CSolver* solver);
void initializeNodeInfoSCC(OrderGraph* graph);
-void DFSNodeVisit(OrderNode* node, VectorOrderNode* finishNodes, bool isReverse);
+void DFSNodeVisit(OrderNode* node, VectorOrderNode* finishNodes, bool isReverse, uint sccNum);
void DFS(OrderGraph* graph, VectorOrderNode* finishNodes);
void DFSReverse(OrderGraph* graph, VectorOrderNode* finishNodes);
void completePartialOrderGraph(OrderGraph* graph);
void localMustAnalysisTotal(OrderGraph *graph);
void localMustAnalysisPartial(OrderGraph *graph);
void orderAnalysis(CSolver* This);
+void decomposeOrder(Order *order, OrderGraph *graph);
#endif /* ORDERGRAPHBUILDER_H */
OrderGraph* This = (OrderGraph*) ourmalloc(sizeof(OrderGraph));
This->nodes = allocHashSetOrderNode(HT_INITIAL_CAPACITY, HT_DEFAULT_FACTOR);
This->order = order;
- initDefVectorOrderNode(&This->scc);
return This;
}
-void addOrderEdge(OrderGraph* graph, OrderNode* node1, OrderNode* node2, Boolean* constr) {
- Polarity polarity=constr->polarity;
- BooleanValue mustval=constr->boolVal;
+void addOrderEdge(OrderGraph* graph, OrderNode* node1, OrderNode* node2, BooleanOrder* constr) {
+ Polarity polarity=constr->base.polarity;
+ BooleanValue mustval=constr->base.boolVal;
Order* order=graph->order;
switch(polarity) {
case P_BOTHTRUEFALSE:
_1to2->polPos = true;
addNewOutgoingEdge(node1, _1to2);
addNewIncomingEdge(node2, _1to2);
- if(constr->polarity == P_TRUE)
+ if(constr->base.polarity == P_TRUE)
break;
}
case P_FALSE:{
return tmp;
}
-void addOrderConstraintToOrderGraph(OrderGraph* graph, Boolean* constr) {
- BooleanOrder* bOrder = (BooleanOrder*) constr;
+void addOrderConstraintToOrderGraph(OrderGraph* graph, BooleanOrder* bOrder) {
OrderNode* from = getOrderNodeFromOrderGraph(graph, bOrder->first);
OrderNode* to = getOrderNodeFromOrderGraph(graph, bOrder->second);
- addOrderEdge(graph, from, to, constr);
+ addOrderEdge(graph, from, to, bOrder);
}
void deleteOrderGraph(OrderGraph* graph){
HashSetOrderNode* nodes;
HashSetOrderEdge* edges;
Order* order;
- VectorOrderNode scc;
};
OrderGraph* allocOrderGraph(Order *order);
-void addOrderConstraintToOrderGraph(OrderGraph* graph, Boolean* constr);
+void addOrderConstraintToOrderGraph(OrderGraph* graph, BooleanOrder* bOrder);
OrderNode* getOrderNodeFromOrderGraph(OrderGraph* graph, uint64_t id);
OrderEdge* getOrderEdgeFromOrderGraph(OrderGraph* graph, OrderNode* begin, OrderNode* end);
-void addOrderEdge(OrderGraph* graph, OrderNode* node1, OrderNode* node2, Boolean* constr);
+void addOrderEdge(OrderGraph* graph, OrderNode* node1, OrderNode* node2, BooleanOrder* constr);
void deleteOrderGraph(OrderGraph* graph);
OrderEdge* getInverseOrderEdge(OrderGraph* graph, OrderEdge *edge);
#endif /* ORDERGRAPH_H */
This->inEdges = allocHashSetOrderEdge(HT_INITIAL_CAPACITY, HT_DEFAULT_FACTOR);
This->outEdges = allocHashSetOrderEdge(HT_INITIAL_CAPACITY, HT_DEFAULT_FACTOR);
This->status=NOTVISITED;
+ This->sccNum=0;
return This;
}
HashSetOrderEdge* inEdges;
HashSetOrderEdge* outEdges;
NodeStatus status;
+ uint sccNum;
};
OrderNode* allocOrderNode(uint64_t id);