[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-glpk] different solutions for same code
From: |
xypron |
Subject: |
Re: [Help-glpk] different solutions for same code |
Date: |
Wed, 2 Sep 2009 21:39:02 -0700 (PDT) |
Hello,
have a look a glp_main() in src/glpapi19.c (of glpk4.39).
Here you find how the defaults of glpsol are set:
glp_init_iocp(&csa->iocp);
csa->iocp.presolve = GLP_ON;
csa->tran = NULL;
csa->graph = NULL;
csa->format = FMT_MPS_FILE;
csa->in_file = NULL;
csa->ndf = 0;
csa->out_dpy = NULL;
csa->solution = SOL_BASIC;
csa->in_res = NULL;
csa->dir = 0;
csa->scale = 1;
csa->out_sol = NULL;
csa->out_res = NULL;
csa->out_bnds = NULL;
csa->check = 0;
csa->new_name = NULL;
csa->out_mps = NULL;
csa->out_freemps = NULL;
csa->out_cpxlp = NULL;
csa->out_pb = NULL;
csa->out_npb = NULL;
csa->log_file = NULL;
csa->crash = USE_ADV_BASIS;
csa->exact = 0;
csa->xcheck = 0;
csa->nomip = 0;
If you set a time limit I guess the parameters scale and crash could make
some difference.
Best regards
Xypron
husalihas wrote:
>
> Hello ,
>
> I wrote a code in "mathprog" to solve MILP problem. The code is running
> fine with GLPK stand alone solver with the following options:
> --dfs --first --mir --gomory --cover --tmlim 10
> the minimum price is : 928173
> But after solving the same code (and same data) using API routines as
> shown below , I got differen price of : 949072 (and different solution).
> Can any body explain why ? is there any thing missing in my C++ code shown
> below?
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <glpk.h>
>
> int main(void)
> { glp_prob *mip;
> glp_iocp parm;
> glp_tran *tran;
> int ret;
> mip = glp_create_prob();
> tran = glp_mpl_alloc_wksp();
> ret = glp_mpl_read_model(tran, "mycode.mod", 1);
> if (ret != 0)
> { fprintf(stderr, "Error on translating model\n");
> goto skip;
> }
> ret = glp_mpl_read_data(tran, "mycode.dat");
> if (ret != 0)
> { fprintf(stderr, "Error on translating data\n");
> goto skip;
> }
> ret = glp_mpl_generate(tran, NULL);
> if (ret != 0)
> { fprintf(stderr, "Error on generating model\n");
> goto skip;
> }
> glp_mpl_build_prob(tran, mip);
> glp_simplex(mip, NULL);
> glp_init_iocp (&parm) ;
> parm.br_tech = GLP_BR_FFV ;
> parm.bt_tech = GLP_BT_DFS ;
> parm.gmi_cuts = GLP_ON ;
> parm.mir_cuts = GLP_ON ;
> parm.cov_cuts = GLP_ON ;
> parm.tm_lim = 10000 ;
> ret = glp_intopt(mip, &parm);
> ret = glp_mpl_postsolve(tran, mip, GLP_MIP);
> if (ret != 0)
> fprintf(stderr, "Error on postsolving model\n");
> glp_print_mip(mip, "mycode.txt");
> skip: glp_mpl_free_wksp(tran);
> glp_delete_prob(mip);
> return 0;
> }
>
--
View this message in context:
http://www.nabble.com/different-solutions-for-same-code-tp25245249p25269699.html
Sent from the Gnu - GLPK - Help mailing list archive at Nabble.com.