[Top][All Lists]

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

Re: [Help-glpk] [Fwd: Get the MIp relative gap at the end of the optimiz

From: oguyon
Subject: Re: [Help-glpk] [Fwd: Get the MIp relative gap at the end of the optimization]
Date: Wed, 20 Jul 2011 08:09:21 -0700 (PDT)

Andrew Makhorin wrote:
> If at least one integer feasible solution was found and you terminated
> the search with glp_ios_terminate, glp_intopt must return GLP_ESTOP and
> glp_mip_status must return GLP_FEAS (even if the mip preprocessor is
> enabled). Please check your code.

Thant you Andrew, you were right. I was confusing different status
(glp_intopt status, glp_mip_status and glp_status and generic basus of the
current solution).

So, now, it works well. If someone is intersted in, here is my code:

public class MyClass MIP implements GlpkCallbackListener{

long start; 

static int maxTime = 5000;
static double mipRelativeGap = 0.01;

protected double solve(){
double resu=-1;

glp_prob model = GLPK.glp_create_prob();

//create here the model !

glp_iocp iocp = new glp_iocp();

start = System.currentTimeMillis(); 
int solveStatus = GLPK.glp_intopt(model, iocp); 

int mipStatus = GLPK.glp_mip_status(model);
boolean success = (mipStatus == GLPKConstants.GLP_OPT || mipStatus ==

        resu = GLPK.glp_mip_obj_val(model);

return resu;
public void callback(glp_tree tree) {
        long now = System.currentTimeMillis();
        if(now - start >= maxTime){
                double mipGap = GLPK.glp_ios_mip_gap(tree);
                if(mipGap <= mipRelativeGap){

View this message in context:
Sent from the Gnu - GLPK - Help mailing list archive at

reply via email to

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