#include <OddCycleConstraint.hh>
Public Member Functions | |
OddCycleConstraint (ABA_MASTER *master, int oddCycleSize, int *nodes, Graph *itsGraph) | |
virtual | ~OddCycleConstraint () |
int | genRow (ABA_ACTIVE< ABA_VARIABLE, ABA_CONSTRAINT > *var, ABA_ROW &row) |
virtual double | coeff (ABA_VARIABLE *var) |
int | getSize () |
bool | isInConstraint (int node) |
virtual bool | equal (ABA_CONVAR *cv) |
virtual const char * | name () |
virtual unsigned | hashKey () |
Definition at line 39 of file OddCycleConstraint.hh.
|
Constructor.
Definition at line 52 of file OddCycleConstraint.cpp. 00053 : 00054 ABA_CONSTRAINT(master, NULL, ABA_CSENSE::Less, (oddCycleSize-1)*0.5, true, 00055 false, false), 00056 oddCycle(oddCycleSize), 00057 itsGraph(theGraph) 00058 { 00059 00060 for (int i=0; i<oddCycleSize; i++) { 00061 oddCycle[i] = nodes[i]; 00062 } 00063 sort(oddCycle.begin(), oddCycle.end()); 00064 00065 // Store this inequality that it can be checked. 00066 ofstream fout(theGraph->getFileName(), ios::app); 00067 for (int i=0; i<oddCycleSize; i++) { 00068 fout << " 1 x_" << itsGraph->translateNode(oddCycle[i]); 00069 } 00070 fout << " < " << (oddCycleSize-1)*0.5 << endl; 00071 fout.close(); 00072 00073 // Calculate the key. 00074 calculateHashKey(); 00075 }
|
|
Destructor. Definition at line 81 of file OddCycleConstraint.cpp.
|
|
Get coefficient of a variable.
Definition at line 115 of file OddCycleConstraint.cpp. References Node::nodeNumber(). 00115 { 00116 00117 // cast ABA_VARIABLE* to NODE* 00118 Node *node = (Node *) var; 00119 // search for this variable in the clique 00120 for (int i=0; i<oddCycle.size(); i++) { 00121 if (node->nodeNumber() == oddCycle[i]) { 00122 return 1.0; 00123 } 00124 } 00125 return 0.0; 00126 }
|
|
Compare if constraint cv is equal to this constraint.
Definition at line 164 of file OddCycleConstraint.cpp. References hashKey(). 00164 { 00165 00166 bool isEqual = true; 00167 if (thisHashKey != ((OddCycleConstraint *)cv)->hashKey()) { 00168 isEqual = false; 00169 } 00170 if (oddCycle.size() != ((OddCycleConstraint *)cv)->getSize()) { 00171 isEqual = false; 00172 } 00173 00174 for(int i=0; i<oddCycle.size(); i++) { 00175 if (!((OddCycleConstraint *)cv)->isInConstraint(oddCycle[i])) { 00176 isEqual = false; 00177 } 00178 } 00179 00180 return isEqual; 00181 }
|
|
Get constraint in sparse format.
Definition at line 91 of file OddCycleConstraint.cpp. 00093 { 00094 // Store the indices of the nodes of the odd cycle. 00095 for (int i=0; i<oddCycle.size(); i++) { 00096 row.insert(oddCycle[i],1.0); 00097 } 00098 // The rhs of the odd cycle.. 00099 row.rhs((oddCycle.size()-1)*0.5); 00100 // Sense of the inequality. 00101 row.sense(ABA_CSENSE::Less); 00102 00103 return row.nnz(); 00104 }
|
|
Get size of odd cycle.
Definition at line 132 of file OddCycleConstraint.cpp.
|
|
This method returns the hashkey of the constraint.
Definition at line 203 of file OddCycleConstraint.cpp. Referenced by equal().
|
|
Checks if node is member of this constraint.
Definition at line 144 of file OddCycleConstraint.cpp. 00144 { 00145 00146 for(int i=0; i<oddCycle.size(); i++) { 00147 if (oddCycle[i] == node) { 00148 return true; 00149 } 00150 } 00151 00152 return false; 00153 }
|
|
This method returns the name of this constraint.
Definition at line 190 of file OddCycleConstraint.cpp.
|