help-glpk
[Top][All Lists]
Advanced

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

Re: [Help-glpk] Sorting Vars?


From: Michael Hennebry
Subject: Re: [Help-glpk] Sorting Vars?
Date: Sat, 9 Feb 2008 11:38:15 -0600 (CST)

On Sat, 9 Feb 2008, Daniel Reckhard wrote:

> after specifying a 3-dimensional array of vars [1] in my model file I am
> surprised to see that this array appears to be unsorted [2]. That is
> very annoying as in the C API vars are always referenced by index [3].
>
> So, to calculate a valid index from a given l, p and b [4] the array has
> to be sorted! Is there any way to do that? Alternatively is there a
> function which returns the var's index for a given name?
>
> Because if sorting doesn't work and there is no such function I'll have
> to write it myself. I.e. parse the problem file into a 3 dimensional
> array in C with the mixed up index number as value. And that's really
> ugly and time-consuming. :(

Unless the documentation says so,
I wouldn't assume that lpx_print_prob prints in index order.
Since you have only one array and no other variables, I think you are in luck.

Difficulties like yours are the reason I usually access
solvers through their APIs instead of a modelling language.

> [1] var x{l in Line, j in Products, b in 0..Bucket} >= 0;
>
> [2] Excerpt retreived with lpx_print_prob
> ...
>  4 x[1,1,2]
>  4 x[1,1,3]
> 10 x[2,1,0]
>  2 x[2,1,1]
>  2 x[2,1,2]
>  2 x[2,1,3]
>  3 x[1,1,4]

-- 
Michael   address@hidden
"Those parts of the system that you can hit with a hammer (not advised)
are called Hardware;  those program instructions that you can only
curse at are called Software."





reply via email to

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