src/lemon/lp_glpk.cc
changeset 1431 ad44b1dd8013
parent 1405 3626c7f10f14
child 1432 46b088b01f88
equal deleted inserted replaced
11:8db21e563aa1 12:eacde8b8c021
    85   {
    85   {
    86     lpx_set_mat_col(lp, i, length,
    86     lpx_set_mat_col(lp, i, length,
    87 		    const_cast<int * >(indices),
    87 		    const_cast<int * >(indices),
    88 		    const_cast<Value * >(values));
    88 		    const_cast<Value * >(values));
    89   }
    89   }
    90   
    90 
       
    91 
       
    92   void LpGlpk::_setCoeff(int row, int col, Value value) 
       
    93   {
       
    94     ///FIXME Of course this is not efficient at all, but GLPK knows not more.
       
    95     // First approach: get one row, apply changes and set it again
       
    96     //(one idea to improve this: maybe it is better to do this with 1 coloumn)
       
    97     
       
    98     int mem_length=2+lpx_get_num_cols(lp);
       
    99     int* indices = new int[mem_length];
       
   100     Value* values = new Value[mem_length];
       
   101     
       
   102 
       
   103     int length=lpx_get_mat_row(lp, row, indices, values);
       
   104 
       
   105     //The following code does not suppose that the elements of the array indices are sorted
       
   106     int i=1;
       
   107     bool found=false;
       
   108     while (i <= length && !found){
       
   109       if (indices[i]==col){
       
   110 	found = true;
       
   111 	values[i]=value;
       
   112       }
       
   113       ++i;
       
   114     }
       
   115     if (!found){
       
   116       ++length;
       
   117       indices[length]=col;
       
   118       values[length]=value;
       
   119     }
       
   120     
       
   121     lpx_set_mat_row(lp, row, length, indices, values);
       
   122     delete [] indices;
       
   123     delete [] values;
       
   124     
       
   125   }
       
   126 
    91   void LpGlpk::_setColLowerBound(int i, Value lo)
   127   void LpGlpk::_setColLowerBound(int i, Value lo)
    92   {
   128   {
    93     if (lo==INF) {
   129     if (lo==INF) {
    94       //FIXME error
   130       //FIXME error
    95     }
   131     }