[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-glpk] Help needed with basis things!

From: HBuesching04
Subject: [Help-glpk] Help needed with basis things!
Date: Thu, 01 Feb 2007 07:44:57 +0100


I have made a routine, which is a prototype of a maybe needfull 
function. It deals with problems where the optimal solution consists of 
a subspace and not a point.
A solution within the subsoace is searched which should have more 
integers as the first solution. It works fine, no problems.

But I would like to use this solution to be the actual solution in the 
given problem and do other things after this, but here I get an error 

As I am really not an expert in basis things I would appreciate some 
expertise on the subject.

Best regards

void LP_Search_Integer(LPX *ToBeAdjusted)
 /*prerequisite: ToBeAdjusted is already solved and all variables are 
binaries! */
 /*RealNumberColumns is a global */
 double *obj, obj_value;
 int i, j, *ind;
 int toBeDeleted[2];
 /*Prepare problem */
 RealNumberColumns = lpx_get_num_cols(ToBeAdjusted);
 obj_value = lpx_get_obj_val(ToBeAdjusted);
 obj = ucalloc(RealNumberColumns + 1, sizeof(double));
 ind = ucalloc(RealNumberColumns + 1, sizeof(int));
 for (i=1; i<=RealNumberColumns; i++)
     {obj[i] = lpx_get_obj_coef(ToBeAdjusted, i);
          ind[i] = i;}
 /*Fix objective value*/
 lpx_add_rows(ToBeAdjusted, 1);
 lpx_set_mat_row(ToBeAdjusted, RealNumberRows + 1, RealNumberColumns, 
ind, obj);
 lpx_set_row_bnds(ToBeAdjusted, RealNumberRows + 1, LPX_FX, obj_value, 
 /*Iterate and hereby punish the almost integers variables to become 
 for (j=1; j<=5; j++)
   {for (i=1; i<=RealNumberColumns; i++)
     {lpx_set_obj_coef(ToBeAdjusted, i, 
                      floor(lpx_get_col_prim(ToBeAdjusted, i)) - 
lpx_get_col_prim(ToBeAdjusted, i) + 0.5); 
 /*Undo change*/
 for (i=1; i<=RealNumberColumns; i++)
     lpx_set_obj_coef(ToBeAdjusted, i, obj[i]);
 toBeDeleted[1] = RealNumberRows+1;
 lpx_del_rows(ToBeAdjusted, 1, toBeDeleted);     

 /*This doesn't work anymore */ 
 /*error message "spx_simplex: initial basis is invalid"*/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]