[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-glpk] request for a feature (maximal iteration number or callb
Re: [Help-glpk] request for a feature (maximal iteration number or callback function in glpk_simplex)
Mon, 20 May 2013 19:30:13 +0400
> we used "glp_simplex(..)" in a academic research project in mathematics
> and made good experiences for most of the problems.
Thank you for your interest in glpk.
> There is one (huge and very badly scaled) problem where
> "glp_simplex(..)" fails to find a feasible solution (even after two days
> of computation ...).
> To study better, if an error is in the model problem or which kind of
> (infeasible, but almost feasible) point is reached by "glp_simplex(..)"
> we would like to have a way that
> - 1) either we can set a maximal iteration number or a minimal
> infeasibility measure for "glp_simplex(..)"
You may limit the number of simplex iterations by specifying the control
> - 2) or that we can add a callback function / hook during the run of
> "glp_simplex(..)" that is always called as it possible for the
> output with "glp_term_hook(..)"
Using a callback in the simplex solver would be impractical, because the
solver doesn't work with glp_prob directly. It copies the instance from
glp_prob to its internal data structures, which are not available to the
user via api; so to provide the callback with the current basic solution
the solver would need to copy it back to glp_prob on every iteration.
Besides, if the lp preprocessor is enabled, the internal lp being solved
differs from the original lp passed to the solver.
> remarks to 1) resp. 2):
> 1) There is a regular terminal output by "glp_simplex(..)"
> (as in the manual, p. 51) like
> 10200: obj = 1.333e+00 infeas = 2.545e+001 (0)
> in which a first number appears (here: 10200) for which we would
> like to establish a maximal iteration number.
> But we cannot see a way to do this.
> To set the control parameter "it_lim" (see manual, p. 53) does
> not help, since this does not set a maximum for the number that
> appears in the regular terminal output (we guess it is a limit
> for an inner iteration).
It_lim limits the number of iterations for a particular call to
glp_simplex, e.g. if you specify it_lim = 1000, the solver will perform
at most 1000 iterations independently on current value of iteration
count (that appears on the terminal output).
> Q1) Do you know of a way how we can stop "glp_simplex" to reach
> the iteration number "10200"?
> Or to stop after a certain infeasibility accuracy is reached?
> 2) The hook function should have a parameter "glp_prob * lp" from which
> we can get intermediate information during the run of simplex.
> Q2) Is there a way to establish such a callback function for
> Q3) Is there a way to access the iteration number "10200" from the
> pointer "lp" during the run of "glp_simplex(..)"?
> In the manual (p.20 - 23) it is announced that in the structure
> "glp_prob" there are control parameters and a statistics segment,
> but it is not described further on (in contrary to the first
> four segments).
> We are afraid that there is no way, since we made the following
> We established a hook function with "glp_term_hook(..)". Then,
> we extracted from the const char-pointer "s" (second argument) the
> iteration number and we tried to read from a (detested) global
> pointer variable (that points to "glp_prob"-variable in main()) and
> its double-array the index 21 (seen as a pointer to int).
> After the call of "glp_simplex(..)" in main() we see the iteration
> number "10200" via our global pointer variable, but inside the
> hook function we only see the wrong value "0".
> Q4) Is it true that only after the end of "glp_simplex(..)"
> the data structure "glp_prob" contains the iteration number
> and further solution values (which is too late for us)?
> Thank you in advance for any helping comments resp. answers to our
> questions Q1)-Q4) and thanks for developing the software ... .
It seems to me that it would be much easier to modify the code for your
particular needs rather than to parse the terminal output via
glp_term_hook. The primal simplex code can be found in file
glpk/src/glpspx01.c and the dual simplex code in the file glpspx02.
Please note that you need to disable the lp preprocessor by setting
glp_smcp.presolve to GLP_OFF (and may be not to use automatic scaling)
that will guarantee that the internal lp is the same as your original lp
passed to the solver. Hope this helps.
- Re: [Help-glpk] request for a feature (maximal iteration number or callback function in glpk_simplex),
Andrew Makhorin <=