lemon/lp_glpk.cc
changeset 2328 b4931ae52069
parent 2326 af8c695372be
child 2345 bfcaad2b84e8
equal deleted inserted replaced
18:4ea78acf29ef 19:5fdda2e0d5e0
   211     
   211     
   212       lpx_set_mat_col(lp, col, length, &indices[0], &values[0]);
   212       lpx_set_mat_col(lp, col, length, &indices[0], &values[0]);
   213     }
   213     }
   214   }
   214   }
   215 
   215 
   216   LpGlpk::Value LpGlpk::_getCoeff(int, int)
   216   LpGlpk::Value LpGlpk::_getCoeff(int row, int col)
   217   {
   217   {
   218     ///\todo This is not yet implemented!!!
   218 
       
   219     int length=lpx_get_mat_row(lp, row, 0, 0);
       
   220     
       
   221     std::vector<int> indices(length + 2);
       
   222     std::vector<Value> values(length + 2);
       
   223     
       
   224     lpx_get_mat_row(lp, row, &indices[0], &values[0]);
       
   225     
       
   226     //The following code does not suppose that the elements of the
       
   227     //array indices are sorted
       
   228     for (int i = 1; i <= length; ++i) {
       
   229       if (indices[i]==col){
       
   230 	return values[i];
       
   231       }
       
   232     }
   219     return 0;
   233     return 0;
       
   234 
   220   }
   235   }
   221 
   236 
   222 
   237 
   223   void LpGlpk::_setColLowerBound(int i, Value lo)
   238   void LpGlpk::_setColLowerBound(int i, Value lo)
   224   {
   239   {
   260 	//FIXME error
   275 	//FIXME error
   261       }
   276       }
   262     }
   277     }
   263 
   278 
   264   }
   279   }
       
   280 
       
   281   LpGlpk::Value LpGlpk::_getColLowerBound(int i)
       
   282   {
       
   283     int b=lpx_get_col_type(lp, i);
       
   284       switch (b) {
       
   285       case LPX_LO:
       
   286       case LPX_DB:
       
   287       case LPX_FX:
       
   288 	return lpx_get_col_lb(lp, i);	
       
   289       default: ;
       
   290 	return -INF;
       
   291       }
       
   292   }
   265   
   293   
   266   void LpGlpk::_setColUpperBound(int i, Value up)
   294   void LpGlpk::_setColUpperBound(int i, Value up)
   267   {
   295   {
   268     if (up==-INF) {
   296     if (up==-INF) {
   269       //FIXME error
   297       //FIXME error
   303 	break;
   331 	break;
   304       default: ;
   332       default: ;
   305 	//FIXME error
   333 	//FIXME error
   306       }
   334       }
   307     }
   335     }
       
   336   }
       
   337 
       
   338   LpGlpk::Value LpGlpk::_getColUpperBound(int i)
       
   339   {
       
   340     int b=lpx_get_col_type(lp, i);
       
   341       switch (b) {
       
   342       case LPX_UP:
       
   343       case LPX_DB:
       
   344       case LPX_FX:
       
   345 	return lpx_get_col_ub(lp, i);	
       
   346       default: ;
       
   347 	return INF;
       
   348       }
   308   }
   349   }
   309   
   350   
   310 //   void LpGlpk::_setRowLowerBound(int i, Value lo)
   351 //   void LpGlpk::_setRowLowerBound(int i, Value lo)
   311 //   {
   352 //   {
   312 //     if (lo==INF) {
   353 //     if (lo==INF) {
   421 	  lpx_set_row_bnds(lp, i, LPX_DB, lb, ub);
   462 	  lpx_set_row_bnds(lp, i, LPX_DB, lb, ub);
   422 	}
   463 	}
   423       }
   464       }
   424     }
   465     }
   425 
   466 
       
   467   }
       
   468 
       
   469   void LpGlpk::_getRowBounds(int i, Value &lb, Value &ub)
       
   470   {
       
   471 
       
   472     int b=lpx_get_row_type(lp, i);
       
   473     switch (b) {
       
   474     case LPX_FR:
       
   475     case LPX_UP:
       
   476       lb = -INF;
       
   477 	break;
       
   478     default: 
       
   479       lb=lpx_get_row_lb(lp, i);
       
   480     }
       
   481 
       
   482     switch (b) {
       
   483     case LPX_FR:
       
   484     case LPX_LO:
       
   485       ub = INF;
       
   486 	break;
       
   487     default: 
       
   488       ub=lpx_get_row_ub(lp, i);
       
   489     }
       
   490     
   426   }
   491   }
   427   
   492   
   428   void LpGlpk::_setObjCoeff(int i, Value obj_coef)
   493   void LpGlpk::_setObjCoeff(int i, Value obj_coef)
   429   {
   494   {
   430     //i=0 means the constant term (shift)
   495     //i=0 means the constant term (shift)