Forum Discussion

FICO's avatar
FICO
Community Manager
3 years ago

What does it mean when the parameter XPRS_MIPINFEAS takes the value -1?

Printing getparam("XPRS_MIPINFEAS") produces "-1". What does this mean?

5 Replies

  • FICO's avatar
    FICO
    Community Manager

    This probably means that something went wrong or you are calling this function in a wrong place. Could you provide an example code that reproduces this value? Or at least outline what you are doing and in which situation you are calling this function?

  • FICO's avatar
    FICO
    Community Manager

    Thank you Daniel,

    I am calling this function from cb_preintsol, which, in its turn, is in tree_cut_gen.

    In principle I want to understand if cb_preintsol is triggered every time that an integer solution is found. (I have the impression that sometimes "cb_node" identifies that the current solution is integer, but then cb_preintsol is not triggered; and vice-versa).

    This is why in cb_preintsol I start recovering the LP solution and check myself if its binary variables take integer values. After this is when I see the -1 value for the XPRS_MIPINFEAS parameter with the statement

    writeln('is_int is ... ', is_int, ' parameter XPRS_MIPINFEAS is ...', getparam("XPRS_MIPINFEAS")

    I am adding the beginning of the code of my cb_preintsol procedure (until the write statement), as well as the tree_cut_gen procedure.

    Thanks again,

    Elena

    procedure cb_preintsol(isheur:boolean, cutoff:real)

    declarations

    my_tipo: integer

    my_corte: linctr

    my_corteid: integer

    que_index: integer

    end-declarations 

    writeln("ENTERS preintsol, node: ", getparam("XPRS_nodes"), "ncortes: ", ncorte)

    ncorte:=0

    returned:=false

    is_int:=true

    forall(i in N1) bary(i):=getsol(y(i))

    forall(i,k,r in N1)barz(i,k,r):=getsol(z(i,k,r))

    forall(i in N1| bary(i)>eps) do

    if(1-bary(i)>eps) then

    is_int:=false

    writeln(' y fraccional: i=', i, ' bary(i)=', bary(i))

    break

    else

    forall(k,r in N1|barz(i,k,r)>eps) do

    if(1-barz(i,k,r)>eps) then

    is_int:=false

    writeln('z fraccional, ', i, ' ', k, ' ' , r, ' barz(i,k,r)=', barz(i,k,r))

    break

    end-if

    end-do

    end-if

    end-do

    writeln('is_int is ... ', is_int, ' parameter XPRS_MIPINFEAS is ...', getparam("XPRS_MIPINFEAS"))

    ...

    *****************************************************

    procedure tree_cut_gen 

     setparam("XPRS_CUTSTRATEGY", 0)   ! Disable automatic cuts

     setparam("XPRS_PRESOLVE", 0)    ! Switch presolve off

     setparam("XPRS_EXTRAROWS", 5000)  ! Reserve extra rows in matrix

     feastol:= getparam("XPRS_FEASTOL") ! Get the zero tolerance

     setparam("zerotol", feastol * 10)  ! Set the comparison tolerance of Mosel

     setcallback(XPRS_CB_CM, "cb_node")

      setcallback(XPRS_CB_PREINTSOL, "cb_preintsol")

     end-procedure

  • FICO's avatar
    FICO
    Community Manager

    Hello Elena,

    sorry for the delayed reply.

    The fact that MIPINFEAS returns -1 in the preintsol is a bug. In some situations the code explicitly sets the number of infeasibilities to -1 when a feasible solution is processed. Until this is fixed, it should be safe to check MIPINFEAS <= 0 to check for feasibility.

    However, checking feasibility in a preintsol callback should not be required. This callback is only invoked when Xpress thinks the solution is feasible and gives the user a last chance to reject that solution.

    If you see feasible solutions that are not routed through the preintsol callback then this is a bug. How do you notice that the CM callback identifies a feasible solution but that solution is then not routed through the preintsol callback?

    Note that the CUTMGR (CM) callback was deprecated a long time ago (see here). You should use the OPTNODE callback instead, which is explained here.

  • FICO's avatar
    FICO
    Community Manager

    Hi Daniel,

    Thank you for your repply. I am cheching feasibility of the solutions because I am adding cuts that are, in fact, constraints. Something like when you add subtour elimination costraints in a branch-and-cut fashion for the TSP. I want to make sure that even if a solution is integer is is rejected if it does not satisfy the "feasibility cut".

    In the meantime I am facing another problen, which confuses me very much. Now when I add the violated cuts (either with addcut or with addcuts), not only the execution stops abruptly, but I get a message saying "an unexpected exception ocurred in Mosel/Optimizer. It is UNSAFE to continue. Please save your work and restart". I cannot figure out what is the reason for this. It is true I have changed (slightly) the cuts I am generating, but they are quite similar to the previous ones, which did not give me any problem.

    Is it a problem if cuts are added from pPREINTSOL?

    Thank you again,

    Elena

  • FICO's avatar
    FICO
    Community Manager

    Cuts can be added only from the optnode, cutmgr, and nodelpsolved callbacks (this is documented for the C api here).

    Can you take a look at the examples/mosel/Solving/els.mos example shipped with Xpress? This illustrates how to add cuts from a callback (see the cb_node callback there).

    Usually, what you do in a situation like this are two things:

    • in the preintsol callback you check whether the solution for feasibility and reject it, if it is infeasible.
    • in an optnode callback, you check whether MIPINFEAS is <=0. If so, then you check again and separate and add violated constraints, if there are any.

    With this, the preintsol callback makes sure that no bad nodes are accepted, the optnode callback make sure that these solutions are actually cut off.