1.1 --- a/src/lemon/lp_glpk.cc Thu May 19 11:53:25 2005 +0000
1.2 +++ b/src/lemon/lp_glpk.cc Fri May 20 09:31:25 2005 +0000
1.3 @@ -87,7 +87,43 @@
1.4 const_cast<int * >(indices),
1.5 const_cast<Value * >(values));
1.6 }
1.7 -
1.8 +
1.9 +
1.10 + void LpGlpk::_setCoeff(int row, int col, Value value)
1.11 + {
1.12 + ///FIXME Of course this is not efficient at all, but GLPK knows not more.
1.13 + // First approach: get one row, apply changes and set it again
1.14 + //(one idea to improve this: maybe it is better to do this with 1 coloumn)
1.15 +
1.16 + int mem_length=2+lpx_get_num_cols(lp);
1.17 + int* indices = new int[mem_length];
1.18 + Value* values = new Value[mem_length];
1.19 +
1.20 +
1.21 + int length=lpx_get_mat_row(lp, row, indices, values);
1.22 +
1.23 + //The following code does not suppose that the elements of the array indices are sorted
1.24 + int i=1;
1.25 + bool found=false;
1.26 + while (i <= length && !found){
1.27 + if (indices[i]==col){
1.28 + found = true;
1.29 + values[i]=value;
1.30 + }
1.31 + ++i;
1.32 + }
1.33 + if (!found){
1.34 + ++length;
1.35 + indices[length]=col;
1.36 + values[length]=value;
1.37 + }
1.38 +
1.39 + lpx_set_mat_row(lp, row, length, indices, values);
1.40 + delete [] indices;
1.41 + delete [] values;
1.42 +
1.43 + }
1.44 +
1.45 void LpGlpk::_setColLowerBound(int i, Value lo)
1.46 {
1.47 if (lo==INF) {