[Top][All Lists]

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

Re: [Help-glpk] glp_ios_heur in Java: format of heuristic solution

From: Andrew Makhorin
Subject: Re: [Help-glpk] glp_ios_heur in Java: format of heuristic solution
Date: Mon, 20 Feb 2012 23:22:00 +0300

> I'm using GLPK 4.47 in Java. My aim is to provide a heuristic solution
> which is stored in a double array "soln", with the coefficient of the
> first column being stored at index 1.
> When I use the code as given below, the optimiser happily accepts the
> suggested solution and terminates with an infeasible solution. As I
> understand from the documentation, it doesn't check feasibility of the
> solution provided internally, so I guess the problem is that I provide
> the heuristic solution in a wrong format which is misinterpreted by
> the GLPK. In particular, I wonder whether the provided heuristic
> solution must take the pre-processing stage (reduction of colums, etc)
> into account?

If you provide a solution to the original mip, the mip preprocessor
should be disabled; otherwise the mip solver assumes that you provide a
solution to the preprocessed mip, that probably is not your intention.
To check feasibility of the heuristic solution you can print it to a
text file with glp_print_mip.

>           GlpkCallbackListener myCallback = new GlpkCallbackListener()
> {
>             @Override
>             public void callback(glp_tree tree) {
>                 System.out.println("We were called by library...");
>                 if(GLPK.glp_ios_reason(tree) ==
> GLPKConstants.GLP_IHEUR) {
>                     System.out.println("...and it asked for heuristic
> solution!");
>                     SWIGTYPE_p_double swigSoln =
> GLPK.new_doubleArray(soln.length);

Please check the following statement (shouldn't be i <= ... ?).

>                     for(int i = 1; i < soln.length; i++) {
>                         GLPK.doubleArray_setitem(swigSoln, i,
> soln[i]);
>                     }
>                     GLPK.glp_ios_heur_sol(tree, swigSoln);
>                 }
>             }
> Thanks for your help.
> Simon

reply via email to

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