typedef enum ElementEncodingType ElementEncodingType;
+enum BooleanVarOrdering {CONSTRAINTORDERING=0, CHORONOLOGICALORDERING=1, REVERSEORDERING=2};
+typedef enum BooleanVarOrdering BooleanVarOrdering;
+
Polarity negatePolarity(Polarity This);
bool impliesPolarity(Polarity curr, Polarity goal);
--- /dev/null
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/*
+ * File: VarOrderingOpt.cpp
+ * Author: hamed
+ *
+ * Created on October 11, 2018, 5:31 PM
+ */
+
+#include "varorderingopt.h"
+#include "csolver.h"
+#include "tunable.h"
+#include "satencoder.h"
+#include "elementencoding.h"
+#include "element.h"
+
+VarOrderingOpt::VarOrderingOpt(CSolver *_solver, SATEncoder *_satencoder): Transform(_solver){
+ satencoder = _satencoder;
+}
+
+VarOrderingOpt::~VarOrderingOpt() {
+}
+
+void VarOrderingOpt::doTransform(){
+ BooleanVarOrdering direction = (BooleanVarOrdering)solver->getTuner()->getTunable(VARIABLEORDER, &boolVarOrderingDesc);
+ if ( direction == CONSTRAINTORDERING ){
+ return;
+ }
+
+ uint size = solver->allElements.getSize();
+ if(direction == CHORONOLOGICALORDERING){
+ for (uint i = 0; i < size; i++) {
+ Element *el = solver->allElements.get(i);
+ ElementEncoding *encoding = el->getElementEncoding();
+ if (encoding->getElementEncodingType() == ELEM_UNASSIGNED)
+ continue;
+ satencoder->encodeElementSATEncoder(el);
+ }
+ }else{
+ for (int i = size-1; i>0; i--) {
+ Element *el = solver->allElements.get(i);
+ ElementEncoding *encoding = el->getElementEncoding();
+ if (encoding->getElementEncodingType() == ELEM_UNASSIGNED)
+ continue;
+ satencoder->encodeElementSATEncoder(el);
+ }
+ }
+}
--- /dev/null
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/*
+ * File: VarOrderingOpt.h
+ * Author: hamed
+ *
+ * Created on October 11, 2018, 5:31 PM
+ */
+
+#ifndef VARORDERINGOPT_H
+#define VARORDERINGOPT_H
+
+#include "transform.h"
+
+
+class VarOrderingOpt :Transform {
+public:
+ VarOrderingOpt(CSolver *_solver, SATEncoder *_satencoder);
+ void doTransform();
+ virtual ~VarOrderingOpt();
+private:
+ SATEncoder* satencoder;
+};
+
+#endif /* VARORDERINGOPT_H */
+
CSolver *solver;
BooleanToEdgeMap booledgeMap;
VectorEdge *vector;
+ friend class VarOrderingOpt;
};
void allocElementConstraintVariables(ElementEncoding *ee, uint numVars);
static TunableDesc mustValueBinaryIndex(5, 9, 8);
static TunableDesc NodeEncodingDesc(ELEM_UNASSIGNED, BINARYINDEX, ELEM_UNASSIGNED);
static TunableDesc NaiveEncodingDesc(ONEHOT, BINARYINDEX, ONEHOT);
+static TunableDesc boolVarOrderingDesc(CONSTRAINTORDERING, REVERSEORDERING, REVERSEORDERING);
-enum Tunables {DECOMPOSEORDER, MUSTREACHGLOBAL, MUSTREACHLOCAL, MUSTREACHPRUNE, OPTIMIZEORDERSTRUCTURE, ORDERINTEGERENCODING, PREPROCESS, NODEENCODING, EDGEENCODING, MUSTEDGEPRUNE, ELEMENTOPT,
- ENCODINGGRAPHOPT, ELEMENTOPTSETS, PROXYVARIABLE, MUSTVALUE, NAIVEENCODER};
+enum Tunables {DECOMPOSEORDER, MUSTREACHGLOBAL, MUSTREACHLOCAL, MUSTREACHPRUNE, OPTIMIZEORDERSTRUCTURE, ORDERINTEGERENCODING, PREPROCESS, NODEENCODING, EDGEENCODING, MUSTEDGEPRUNE, ELEMENTOPT,
+ ENCODINGGRAPHOPT, ELEMENTOPTSETS, PROXYVARIABLE, MUSTVALUE, NAIVEENCODER, VARIABLEORDER};
typedef enum Tunables Tunables;
const char *tunableParameterToString(Tunables tunable);
#include "orderedge.h"
#include "orderanalysis.h"
#include "elementopt.h"
+#include "varorderingopt.h"
#include <time.h>
#include <stdarg.h>
naiveEncodingDecision(this);
// eg.validate();
+ VarOrderingOpt bor(this, satEncoder);
+ bor.doTransform();
+
time2 = getTimeNano();
model_print("Encoding Graph Time: %f\n", (time2 - time1) / NANOSEC);
-
+
satEncoder->encodeAllSATEncoder(this);
time1 = getTimeNano();
long long elapsedTime;
long satsolverTimeout;
friend class ElementOpt;
+ friend class VarOrderingOpt;
};
inline CompOp flipOp(CompOp op) {