145 void LpCplex::_setCoeff(int row, int col, Value value) |
145 void LpCplex::_setCoeff(int row, int col, Value value) |
146 { |
146 { |
147 CPXchgcoef(env, lp, row, col, value); |
147 CPXchgcoef(env, lp, row, col, value); |
148 } |
148 } |
149 |
149 |
|
150 LpCplex::Value LpCplex::_getCoeff(int row, int col) |
|
151 { |
|
152 LpCplex::Value value; |
|
153 CPXgetcoef(env, lp, row, col, &value); |
|
154 return value; |
|
155 } |
|
156 |
150 void LpCplex::_setColLowerBound(int i, Value value) |
157 void LpCplex::_setColLowerBound(int i, Value value) |
151 { |
158 { |
152 int indices[1]; |
159 int indices[1]; |
153 indices[0]=i; |
160 indices[0]=i; |
154 char lu[1]; |
161 char lu[1]; |
156 Value bd[1]; |
163 Value bd[1]; |
157 bd[0]=value; |
164 bd[0]=value; |
158 status = CPXchgbds(env, lp, 1, indices, lu, bd); |
165 status = CPXchgbds(env, lp, 1, indices, lu, bd); |
159 |
166 |
160 } |
167 } |
|
168 |
|
169 LpCplex::Value LpCplex::_getColLowerBound(int i) |
|
170 { |
|
171 LpCplex::Value x; |
|
172 CPXgetlb (env, lp, &x, i, i); |
|
173 return x; |
|
174 } |
161 |
175 |
162 void LpCplex::_setColUpperBound(int i, Value value) |
176 void LpCplex::_setColUpperBound(int i, Value value) |
163 { |
177 { |
164 int indices[1]; |
178 int indices[1]; |
165 indices[0]=i; |
179 indices[0]=i; |
166 char lu[1]; |
180 char lu[1]; |
167 lu[0]='U'; |
181 lu[0]='U'; |
168 Value bd[1]; |
182 Value bd[1]; |
169 bd[0]=value; |
183 bd[0]=value; |
170 status = CPXchgbds(env, lp, 1, indices, lu, bd); |
184 status = CPXchgbds(env, lp, 1, indices, lu, bd); |
|
185 } |
|
186 |
|
187 LpCplex::Value LpCplex::_getColUpperBound(int i) |
|
188 { |
|
189 LpCplex::Value x; |
|
190 CPXgetub (env, lp, &x, i, i); |
|
191 return x; |
171 } |
192 } |
172 |
193 |
173 //This will be easier to implement |
194 //This will be easier to implement |
174 void LpCplex::_setRowBounds(int i, Value lb, Value ub) |
195 void LpCplex::_setRowBounds(int i, Value lb, Value ub) |
175 { |
196 { |
240 // // } |
261 // // } |
241 |
262 |
242 // // status = CPXchgcoef(env, lp, i, -2, value_rng); |
263 // // status = CPXchgcoef(env, lp, i, -2, value_rng); |
243 // } |
264 // } |
244 |
265 |
|
266 void LpCplex::_getRowBounds(int i, Value &lb, Value &ub) |
|
267 { |
|
268 char sense; |
|
269 CPXgetsense(env, lp, &sense,i,i); |
|
270 lb=-INF; |
|
271 ub=INF; |
|
272 switch (sense) |
|
273 { |
|
274 case 'L': |
|
275 CPXgetcoef(env, lp, i, -1, &ub); |
|
276 break; |
|
277 case 'G': |
|
278 CPXgetcoef(env, lp, i, -1, &lb); |
|
279 break; |
|
280 case 'E': |
|
281 CPXgetcoef(env, lp, i, -1, &lb); |
|
282 ub=lb; |
|
283 break; |
|
284 case 'R': |
|
285 CPXgetcoef(env, lp, i, -1, &lb); |
|
286 Value x; |
|
287 CPXgetcoef(env, lp, i, -2, &x); |
|
288 ub=lb+x; |
|
289 break; |
|
290 } |
|
291 } |
|
292 |
245 void LpCplex::_setObjCoeff(int i, Value obj_coef) |
293 void LpCplex::_setObjCoeff(int i, Value obj_coef) |
246 { |
294 { |
247 CPXchgcoef(env, lp, -1, i, obj_coef); |
295 CPXchgcoef(env, lp, -1, i, obj_coef); |
|
296 } |
|
297 |
|
298 LpCplex::Value LpCplex::_getObjCoeff(int i) |
|
299 { |
|
300 Value x; |
|
301 CPXgetcoef(env, lp, -1, i, &x); |
|
302 return x; |
248 } |
303 } |
249 |
304 |
250 void LpCplex::_clearObj() |
305 void LpCplex::_clearObj() |
251 { |
306 { |
252 for (int i=0;i< CPXgetnumcols(env, lp);++i){ |
307 for (int i=0;i< CPXgetnumcols(env, lp);++i){ |