[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-glpk] [Fwd: Need help in callback routine for GLP_IBRANCH]
From: |
Andrew Makhorin |
Subject: |
Re: [Help-glpk] [Fwd: Need help in callback routine for GLP_IBRANCH] |
Date: |
Mon, 04 Jul 2011 15:09:11 +0400 |
> I am using GLPK callback routine to change the behavior of branch and
> bound method.
> I use glp_ios_reason to determine the reason for calling the call-back
> routine.
>
> In this, for the reason GLP_IBRANCH, I have to change rule to select
> next variable to branch on.
> For this, I need the values of all the variables for LP relaxation
> solution at down branch (when candidate variable is set to 0) and up
> branch (when candidate variable is set to 1).
> I am using following logic for getting these values, but I get the error
> that glp_simplex is not allowed at this step.
> Will you please guide me on this?
>
> [ Note:
> here j is the candidate variable index obtained from the routine
> glp_ios_can_branch(tree, j).
> 'numcol' is the total number of variables in sub-problem obtained from
> the routine glp_get_num_cols(glp_ios_get_prob(tree)).
> ]
>
> glp_set_col_bnds(glp_ios_get_prob(tree), j, GLP_UP, 0.0, 0.0);
> glp_simplex(glp_ios_get_prob(tree),NULL);
> for(i=1,j=1; j<= numcol ; i++,j++)
> xlf[i] = glp_get_col_prim(glp_ios_get_prob(tree),j);
>
>
> glp_set_col_bnds(glp_ios_get_prob(tree), j, GLP_LO, 1.0, 0.0);
> glp_simplex(glp_ios_get_prob(tree),NULL);
> for(i=1,j=1; j<= numcol ; i++,j++)
> xuf[i] = glp_get_col_prim(glp_ios_get_prob(tree),j);
>
Since within the callback routine the problem object is used by the mip
solver, you cannot change it arbitrarily--the operations that change the
problem object are limited to changing row/column bounds, adding rows,
and removing rows added to the current subproblem. In partcular,
glp_simplex may change the current basis and solution components, so it
cannot be used for the current subproblem. For more details please see
the glpk reference manual.
If you need to fix some variables and then call glp_simplex (I guess
you'd like to implement something like a strong branching), you may
create a copy of the current subproblem with the routine glp_clone_prob,
perform all necessary calculations, and then delete the copy on exit
from the callback routine.