0
13
0
... | ... |
@@ -96,2 +96,14 @@ |
96 | 96 |
|
97 |
int CbcMip::_addRow(Value l, ExprIterator b, ExprIterator e, Value u) { |
|
98 |
std::vector<int> indexes; |
|
99 |
std::vector<Value> values; |
|
100 |
|
|
101 |
for(ExprIterator it = b; it != e; ++it) { |
|
102 |
indexes.push_back(it->first); |
|
103 |
values.push_back(it->second); |
|
104 |
} |
|
105 |
|
|
106 |
_prob->addRow(values.size(), &indexes.front(), &values.front(), l, u); |
|
107 |
return _prob->numberRows() - 1; |
|
108 |
} |
|
97 | 109 |
... | ... |
@@ -80,2 +80,15 @@ |
80 | 80 |
|
81 |
int ClpLp::_addRow(Value l, ExprIterator b, ExprIterator e, Value u) { |
|
82 |
std::vector<int> indexes; |
|
83 |
std::vector<Value> values; |
|
84 |
|
|
85 |
for(ExprIterator it = b; it != e; ++it) { |
|
86 |
indexes.push_back(it->first); |
|
87 |
values.push_back(it->second); |
|
88 |
} |
|
89 |
|
|
90 |
_prob->addRow(values.size(), &indexes.front(), &values.front(), l, u); |
|
91 |
return _prob->numberRows() - 1; |
|
92 |
} |
|
93 |
|
|
81 | 94 |
... | ... |
@@ -113,2 +113,35 @@ |
113 | 113 |
|
114 |
int CplexBase::_addRow(Value lb, ExprIterator b, |
|
115 |
ExprIterator e, Value ub) { |
|
116 |
int i = CPXgetnumrows(cplexEnv(), _prob); |
|
117 |
if (lb == -INF) { |
|
118 |
const char s = 'L'; |
|
119 |
CPXnewrows(cplexEnv(), _prob, 1, &ub, &s, 0, 0); |
|
120 |
} else if (ub == INF) { |
|
121 |
const char s = 'G'; |
|
122 |
CPXnewrows(cplexEnv(), _prob, 1, &lb, &s, 0, 0); |
|
123 |
} else if (lb == ub){ |
|
124 |
const char s = 'E'; |
|
125 |
CPXnewrows(cplexEnv(), _prob, 1, &lb, &s, 0, 0); |
|
126 |
} else { |
|
127 |
const char s = 'R'; |
|
128 |
double len = ub - lb; |
|
129 |
CPXnewrows(cplexEnv(), _prob, 1, &lb, &s, &len, 0); |
|
130 |
} |
|
131 |
|
|
132 |
std::vector<int> indices; |
|
133 |
std::vector<int> rowlist; |
|
134 |
std::vector<Value> values; |
|
135 |
|
|
136 |
for(ExprIterator it=b; it!=e; ++it) { |
|
137 |
indices.push_back(it->first); |
|
138 |
values.push_back(it->second); |
|
139 |
rowlist.push_back(i); |
|
140 |
} |
|
141 |
|
|
142 |
CPXchgcoeflist(cplexEnv(), _prob, values.size(), |
|
143 |
&rowlist.front(), &indices.front(), &values.front()); |
|
144 |
|
|
145 |
return i; |
|
146 |
} |
|
114 | 147 |
... | ... |
@@ -61,2 +61,38 @@ |
61 | 61 |
|
62 |
int GlpkBase::_addRow(Value lo, ExprIterator b, |
|
63 |
ExprIterator e, Value up) { |
|
64 |
int i = glp_add_rows(lp, 1); |
|
65 |
|
|
66 |
if (lo == -INF) { |
|
67 |
if (up == INF) { |
|
68 |
glp_set_row_bnds(lp, i, GLP_FR, lo, up); |
|
69 |
} else { |
|
70 |
glp_set_row_bnds(lp, i, GLP_UP, lo, up); |
|
71 |
} |
|
72 |
} else { |
|
73 |
if (up == INF) { |
|
74 |
glp_set_row_bnds(lp, i, GLP_LO, lo, up); |
|
75 |
} else if (lo != up) { |
|
76 |
glp_set_row_bnds(lp, i, GLP_DB, lo, up); |
|
77 |
} else { |
|
78 |
glp_set_row_bnds(lp, i, GLP_FX, lo, up); |
|
79 |
} |
|
80 |
} |
|
81 |
|
|
82 |
std::vector<int> indexes; |
|
83 |
std::vector<Value> values; |
|
84 |
|
|
85 |
indexes.push_back(0); |
|
86 |
values.push_back(0); |
|
87 |
|
|
88 |
for(ExprIterator it = b; it != e; ++it) { |
|
89 |
indexes.push_back(it->first); |
|
90 |
values.push_back(it->second); |
|
91 |
} |
|
92 |
|
|
93 |
glp_set_mat_row(lp, i, values.size() - 1, |
|
94 |
&indexes.front(), &values.front()); |
|
95 |
return i; |
|
96 |
} |
|
97 |
|
|
62 | 98 |
void GlpkBase::_eraseCol(int i) { |
... | ... |
@@ -945,2 +945,10 @@ |
945 | 945 |
|
946 |
virtual int _addRow(Value l, ExprIterator b, ExprIterator e, Value u) { |
|
947 |
int row = _addRow(); |
|
948 |
_setRowCoeffs(row, b, e); |
|
949 |
_setRowLowerBound(row, l); |
|
950 |
_setRowUpperBound(row, u); |
|
951 |
return row; |
|
952 |
} |
|
953 |
|
|
946 | 954 |
virtual void _eraseCol(int col) = 0; |
... | ... |
@@ -1209,4 +1217,6 @@ |
1209 | 1217 |
Row addRow(Value l,const Expr &e, Value u) { |
1210 |
Row r=addRow(); |
|
1211 |
row(r,l,e,u); |
|
1218 |
Row r; |
|
1219 |
e.simplify(); |
|
1220 |
r._id = _addRowId(_addRow(l - *e, ExprIterator(e.comps.begin(), cols), |
|
1221 |
ExprIterator(e.comps.end(), cols), u - *e)); |
|
1212 | 1222 |
return r; |
... | ... |
@@ -1219,4 +1229,8 @@ |
1219 | 1229 |
Row addRow(const Constr &c) { |
1220 |
Row r=addRow(); |
|
1221 |
row(r,c); |
|
1230 |
Row r; |
|
1231 |
c.expr().simplify(); |
|
1232 |
r._id = _addRowId(_addRow(c.lowerBounded()?c.lowerBound():-INF, |
|
1233 |
ExprIterator(c.expr().comps.begin(), cols), |
|
1234 |
ExprIterator(c.expr().comps.end(), cols), |
|
1235 |
c.upperBounded()?c.upperBound():INF)); |
|
1222 | 1236 |
return r; |
... | ... |
@@ -93,2 +93,15 @@ |
93 | 93 |
|
94 |
int SoplexLp::_addRow(Value l, ExprIterator b, ExprIterator e, Value u) { |
|
95 |
soplex::DSVector v; |
|
96 |
for (ExprIterator it = b; it != e; ++it) { |
|
97 |
v.add(it->first, it->second); |
|
98 |
} |
|
99 |
soplex::LPRow r(l, v, u); |
|
100 |
soplex->addRow(r); |
|
101 |
|
|
102 |
_row_names.push_back(std::string()); |
|
103 |
|
|
104 |
return soplex->nRows() - 1; |
|
105 |
} |
|
106 |
|
|
94 | 107 |
0 comments (0 inline)