#include "csolver.h"
#include "tunable.h"
#include "qsort.h"
+#include "subgraph.h"
+#include "elementencoding.h"
+#include "boolean.h"
EncodingGraph::EncodingGraph(CSolver * _solver) :
solver(_solver) {
decideEdges();
}
+void EncodingGraph::encode() {
+ SetIteratorEncodingSubGraph * itesg=subgraphs.iterator();
+ while(itesg->hasNext()) {
+ EncodingSubGraph *sg=itesg->next();
+ sg->encode();
+ }
+ delete itesg;
+
+ ElementIterator it(solver);
+ while(it.hasNext()) {
+ Element * e = it.next();
+ switch(e->type) {
+ case ELEMSET:
+ case ELEMFUNCRETURN: {
+ ElementEncoding *encoding=e->getElementEncoding();
+ if (encoding->getElementEncodingType() == ELEM_UNASSIGNED) {
+ //Do assignment...
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ }
+
+}
+
void EncodingGraph::mergeNodes(EncodingNode *first, EncodingNode *second) {
EncodingSubGraph *graph1=graphMap.get(first);
EncodingSubGraph *graph2=graphMap.get(second);
if (graph1 == NULL && graph2 == NULL) {
graph1 = new EncodingSubGraph();
+ subgraphs.add(graph1);
graphMap.put(first, graph1);
graph1->addNode(first);
}
graph1->addNode(node);
graphMap.put(node, graph1);
}
+ subgraphs.remove(graph2);
delete nodeit;
delete graph2;
} else {
return numEquals * min + numComparisons * lSize * rSize;
}
-EncodingSubGraph::EncodingSubGraph() :
- encodingSize(0),
- numElements(0) {
-}
-
-uint EncodingSubGraph::estimateNewSize(EncodingSubGraph *sg) {
- uint newSize=0;
- SetIteratorEncodingNode * nit = sg->nodes.iterator();
- while(nit->hasNext()) {
- EncodingNode *en = nit->next();
- uint size=estimateNewSize(en);
- if (size > newSize)
- newSize = size;
- }
- delete nit;
- return newSize;
-}
-
-uint EncodingSubGraph::estimateNewSize(EncodingNode *n) {
- SetIteratorEncodingEdge * eeit = n->edges.iterator();
- uint newsize=n->getSize();
- while(eeit->hasNext()) {
- EncodingEdge * ee = eeit->next();
- if (ee->left != NULL && ee->left != n && nodes.contains(ee->left)) {
- uint intersectSize = n->s->getUnionSize(ee->left->s);
- if (intersectSize > newsize)
- newsize = intersectSize;
- }
- if (ee->right != NULL && ee->right != n && nodes.contains(ee->right)) {
- uint intersectSize = n->s->getUnionSize(ee->right->s);
- if (intersectSize > newsize)
- newsize = intersectSize;
- }
- if (ee->dst != NULL && ee->dst != n && nodes.contains(ee->dst)) {
- uint intersectSize = n->s->getUnionSize(ee->dst->s);
- if (intersectSize > newsize)
- newsize = intersectSize;
- }
- }
- delete eeit;
- return newsize;
-}
-
-void EncodingSubGraph::addNode(EncodingNode *n) {
- nodes.add(n);
- uint newSize=estimateNewSize(n);
- numElements += n->elements.getSize();
- if (newSize > encodingSize)
- encodingSize=newSize;
-}
-SetIteratorEncodingNode * EncodingSubGraph::nodeIterator() {
- return nodes.iterator();
-}