help-glpk
[Top][All Lists]
Advanced

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

Re: [Help-glpk] Name index discrepancies?


From: Andrew Makhorin
Subject: Re: [Help-glpk] Name index discrepancies?
Date: Wed, 19 Sep 2007 06:30:47 +0400

> I am solving a binary integer program and then, after examining
> the solution, I modify the data and solve again.   I am using the
> GLPK API 4.19.

> My question is regarding the name index functions.  I am
> essentially doing something like this (I think these are the
> important/relevant parts of the code, if more is necessary, please
> let me know):


> /* Set up the problem */
> bip = lpx_read_model(argv[INDEX_MODL], argv[INDEX_DATA], NULL);
> glp_init_smcp(simplex_control_params);

> /* Create the name index */
> glp_create_index(bip);

> /* To illustrate my confusion */
> printf("COLUMN w[FDX1857_1511,OAK,169] has index %d\n",
> glp_find_col(bip, "w[FDX1857_1511,OAK,169]"));

> /* Solve */
> glp_simplex(bip, simplex_control_params);
> lpx_integer(bip);

> /* 'Delay_Costs' is my objective function */
> i = glp_find_row(bip, "Delay_Costs");
> len = glp_get_mat_row(bip, i, ind, val);

> /* Print out each column name present in the objective fcn */
> for( j = 1; j <= len; j++) 
>    printf("  Row %d Col %d variable %s\n", i, j, glp_get_col_name(bip, 
> ind[j]));

> /* To further illustrate */
> printf("COLUMN w[FDX1857_1511,OAK,169] has index %d\n",
> glp_find_col(bip, "w[FDX1857_1511,OAK,169]"));




> This program will output something like this:


> COLUMN w[FDX1857_1511,OAK,169] has index 744
> ...
> Row 1 Col 744 variable w[N50LG_292,MCC,50]
> Row 1 Col 745 variable w[N50LG_292,MCC,49]
> ...
> COLUMN w[FDX1857_1511,OAK,169] has index 744


> So my question is: does the ordinal # of the column (as returned
> by glp_find_col()) not correspond to the column number as I step
> through the objective function as above?  Is this a bug or a
> misunderstanding on my part?  Any clarification or guidance
> appreciated... this issue has taken up a good many hours for me
> already!  If any further information would be helpful, please just
> let me know, I'd be happy to provide it.

You are mistaken in the fragment:

/* Print out each column name present in the objective fcn */
for( j = 1; j <= len; j++)
   printf("  Row %d Col %d variable %s\n", i, j, glp_get_col_name(bip, ind[j]));

You print j while you should print ind[j].





reply via email to

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