diff -r 48b4f46f9d4e -r ad44b1dd8013 src/lemon/lp_glpk.cc --- a/src/lemon/lp_glpk.cc Thu May 19 11:53:25 2005 +0000 +++ b/src/lemon/lp_glpk.cc Fri May 20 09:31:25 2005 +0000 @@ -87,7 +87,43 @@ const_cast(indices), const_cast(values)); } - + + + void LpGlpk::_setCoeff(int row, int col, Value value) + { + ///FIXME Of course this is not efficient at all, but GLPK knows not more. + // First approach: get one row, apply changes and set it again + //(one idea to improve this: maybe it is better to do this with 1 coloumn) + + int mem_length=2+lpx_get_num_cols(lp); + int* indices = new int[mem_length]; + Value* values = new Value[mem_length]; + + + int length=lpx_get_mat_row(lp, row, indices, values); + + //The following code does not suppose that the elements of the array indices are sorted + int i=1; + bool found=false; + while (i <= length && !found){ + if (indices[i]==col){ + found = true; + values[i]=value; + } + ++i; + } + if (!found){ + ++length; + indices[length]=col; + values[length]=value; + } + + lpx_set_mat_row(lp, row, length, indices, values); + delete [] indices; + delete [] values; + + } + void LpGlpk::_setColLowerBound(int i, Value lo) { if (lo==INF) {