[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-glpk] Sorting Vars?
From: |
Andrew Makhorin |
Subject: |
Re: [Help-glpk] Sorting Vars? |
Date: |
Sat, 9 Feb 2008 22:39:25 +0300 |
> 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!
Not necessary. It depends on implementation. Besides, arrays can be
sparse, in which case sorting is useless.
> Is there any way to do that? Alternatively is there a
> function which returns the var's index for a given name?
Yes. It is glp_find_col.
> 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. :(
> [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]
> ...
> [3] E.g. lpx_set_mat_row needs a one-dimensional index to reference the
> according variable.
> [4] E.g. index = l * P_max * B_max + p * B_max + b;
> Thanks for your time,