#include <RankConstraint.hh>
Public Member Functions | |
RankConstraint (ABA_MASTER *master, vector< int > *nodes, int rhs, Graph *theGraph) | |
RankConstraint (ABA_MASTER *master, vector< int > *nodes, int rhs, bool dynamic, Graph *theGraph) | |
virtual | ~RankConstraint () |
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 RankConstraint.hh.
|
Constructor.
Definition at line 46 of file RankConstraint.cpp. References Graph::getFileName(), and Graph::translateNode(). 00047 : 00048 ABA_CONSTRAINT(master, NULL, ABA_CSENSE::Less, rhs, true, false, false), 00049 itsNodes(nodes->size()), 00050 itsGraph(theGraph), 00051 itsRhs(rhs) 00052 { 00053 // Store this inequality that it can be checked. 00054 ofstream fout(theGraph->getFileName(), ios::app); 00055 00056 for (int i=0; i<nodes->size(); i++) { 00057 itsNodes[i] = (*nodes)[i]; 00058 fout << " 1 x_" << itsGraph->translateNode(itsNodes[i]); 00059 } 00060 fout << " < " << itsRhs << endl; 00061 fout.close(); 00062 00063 // Calculate the key. 00064 calculateHashKey(); 00065 }
|
|
Constructor.
Definition at line 76 of file RankConstraint.cpp. References Graph::getFileName(), and Graph::translateNode(). 00077 : 00078 ABA_CONSTRAINT(master, NULL, ABA_CSENSE::Less, rhs, dynamic, false, false), 00079 itsNodes(nodes->size()), 00080 itsGraph(theGraph), 00081 itsRhs(rhs) 00082 { 00083 // Store this inequality that it can be checked. 00084 ofstream fout(theGraph->getFileName(), ios::app); 00085 00086 for (int i=0; i<nodes->size(); i++) { 00087 itsNodes[i] = (*nodes)[i]; 00088 fout << " 1 x_" << itsGraph->translateNode(itsNodes[i]); 00089 } 00090 fout << " < " << itsRhs << endl; 00091 fout.close(); 00092 00093 // Calculate the key. 00094 calculateHashKey(); 00095 }
|
|
Destructor. Definition at line 101 of file RankConstraint.cpp.
|
|
Get coefficient of a variable.
Definition at line 133 of file RankConstraint.cpp. References Node::nodeNumber(). 00133 { 00134 00135 // Cast ABA_VARIABLE* to NODE*. 00136 Node *node = (Node *) var; 00137 // search for this variable in the clique 00138 for (int i=0; i<itsNodes.size(); i++) { 00139 if (node->nodeNumber() == itsNodes[i]) { 00140 return 1.0; 00141 } 00142 } 00143 return 0.0; 00144 }
|
|
Compare if constraint cv is equal to this constraint.
Definition at line 182 of file RankConstraint.cpp. References hashKey(). 00182 { 00183 00184 bool isEqual = true; 00185 if (thisHashKey != ((RankConstraint *)cv)->hashKey()) { 00186 isEqual = false; 00187 } 00188 if (itsNodes.size() != ((RankConstraint *)cv)->getSize()) { 00189 isEqual = false; 00190 } 00191 00192 for(int i=0; i<itsNodes.size(); i++) { 00193 if (!((RankConstraint *)cv)->isInConstraint(itsNodes[i])) { 00194 isEqual = false; 00195 } 00196 } 00197 00198 return isEqual; 00199 }
|
|
Get constraint in sparse format.
Definition at line 111 of file RankConstraint.cpp. 00113 { 00114 00115 for (int i=0; i<itsNodes.size(); i++) { 00116 row.insert(itsNodes[i],1.0); 00117 } 00118 row.rhs(itsRhs); 00119 row.sense(ABA_CSENSE::Less); 00120 00121 return row.nnz(); 00122 }
|
|
Get size of clique.
Definition at line 150 of file RankConstraint.cpp.
|
|
This method returns the hashkey of the constraint.
Definition at line 221 of file RankConstraint.cpp. Referenced by equal().
|
|
Checks if node is member of this constraint.
Definition at line 162 of file RankConstraint.cpp. 00162 { 00163 00164 for(int i=0; i<itsNodes.size(); i++) { 00165 if (itsNodes[i] == node) { 00166 return true; 00167 } 00168 } 00169 00170 return false; 00171 }
|
|
This method returns the name of this constraint.
Definition at line 208 of file RankConstraint.cpp.
|