Obtaining the best lower bound through AMPL

185 views
Skip to first unread message

at

unread,
Sep 21, 2016, 11:07:18 AM9/21/16
to AMPL Modeling Language
Is it possible to obtain the best lower bound (on a minimization problem), i.e. the best optimal value achieved through a relaxation?

The specific solvers I am concerned with are KNITRO, Couenne and BARON, but this would apply to any sort of mixed integer solver.

The reason behind this is that in my application it is more important to have an infeasible underestimate of the minimum rather than a feasible overestimate. I would like to be able to end the algorithm after a set amount of time and then recover the value of the objective at this infeasible underestimate.

Robert Fourer

unread,
Sep 21, 2016, 3:10:55 PM9/21/16
to am...@googlegroups.com
Best bounds can be returned to AMPL, but the mechanism is different for each solver.

In a new update to BARON for AMPL made available today, you can specify, say,

option baron_options 'maxtime 1000 objbound';

and then after BARON returns control to AMPL, you can use objective suffixes .obj_lb and .obj_ub to access the best lower and upper bounds found during the solve. For example, if the objective is Total_Cost then you can display these bounds with

ampl: display Total_Cost.obj_lb, Total_Cost.obj_ub;
Total_Cost.obj_lb = 227125
Total_Cost.obj_ub = 354277

Since this is a minimization and BARON returns the best solution found so far, the value for Total_Cost.obj_ub will the same as the value of Total_Cost.

Knitro for AMPL has similar suffixes .relaxbnd and .incumbent which are the lower and upper bounds, respectively, for a minimization. They are generated automatically when solving problems that have integer variables.

Couenne displays lower and upper bounds in its listing but I do not see where the Couenne-AMPL interface returns these bounds to AMPL. You could take this up with the Couenne development team, who also supply the AMPL interface for Couenne. If they make an update then we can generate and post new Couenne for AMPL binaries on our website.

Bob Fourer
am...@googlegroups.com

=======

at

unread,
Sep 22, 2016, 4:18:45 PM9/22/16
to AMPL Modeling Language, 4...@ampl.com
Thanks Bob. I updated my BARON binary and this works just as expected.

vah...@uci.edu

unread,
Feb 3, 2017, 5:31:57 PM2/3/17
to AMPL Modeling Language, 4...@ampl.com
Hi Robert,

I specified:
suffix obj_ub OUT;

But, AMPL returns 0 when I type:
display obj. obj_ub;

I checked my sumfile and it is clear that the lower bound is 2.6.

Thank you,
Vahid Nourbakhsh
UCI

Robert Fourer

unread,
Feb 6, 2017, 10:34:37 AM2/6/17
to am...@googlegroups.com
The suffix .obj_ub only works if you are using BARON and you have included 'objbound' in your baron_options string. If this is your situation, then also use the command "shell 'baron -v';" to confirm that you are running a version of BARON dated 20160921 (21 Sept 2016) or later. If that also checks out, then try posting some more detail such as the complete text of your AMPL session and/or your files.

Bob Fourer
am...@googlegroups.com

=======

Seyedvahid Nourbakhsh

unread,
Feb 6, 2017, 1:45:23 PM2/6/17
to am...@googlegroups.com
Thank you Bob,

The problem should be my BARON version. I will update it and try again.

Best,
Vahid
> --
> You received this message because you are subscribed to a topic in the Google Groups "AMPL Modeling Language" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/ampl/Vi0ayFJAf38/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to ampl+uns...@googlegroups.com.
> To post to this group, send email to am...@googlegroups.com.
> Visit this group at https://groups.google.com/group/ampl.
> For more options, visit https://groups.google.com/d/optout.

q...@umn.edu

unread,
Jul 1, 2018, 6:20:31 AM7/1/18
to AMPL Modeling Language
Hi Bob

I have a related question about obtaining the best relaxation bound of Baron at termination. I'm writing an AMPL script to solve a set of instances with Baron (version 18.5.8), and would like to store the best relaxation bound in a file if the instance is solved to optimality. Part of my AMPL script looks like the following:

option solver Baron;
option baron_options 'maxtime=600 objbound';

if solve_result = "solved" then {
        display l2norm_squared.obj_ub > ($outdir & filename & ".out");
}

I'm solving a maximization problem, and l2norm_squared is the name of the objective function.

But AMPL won't allow me to run this script and gives the following error message:

Bad suffix .obj_ub for l2norm_squared
context:  display  >>> l2norm_squared.obj_ub  <<< > ($outdir & filename & ".out");
Possible suffix values for l2norm_squared.suffix:
    astatus   exitcode   message   no
    relax     result     sense     sno
    sstatus   stage      val   

I know AMPL is trying to check possible errors before running the script, but if the instance is solved to optimality, the objective should have the suffix "obj_ub". Is there anywhere to avoid this checking and let the script run?

Thanks a lot!

Qie

AMPL Google Group

unread,
Jul 2, 2018, 12:59:57 PM7/2/18
to Ampl Modeling Language
I don't see solve command in your script? Did you solve the optimization problem?

--
Dr. Paras Tiwari
am...@googlegroups.com
{#HS:612193683-12604#}
--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ampl+uns...@googlegroups.com.

Qie He

unread,
Jul 2, 2018, 5:51:13 PM7/2/18
to am...@googlegroups.com
Thanks for the help. Yes, the script includes the solve command. The code I posted is just part of the script.

Below is a more complete version of the code. If I comment out the third line from the last " display l2norm_squared.obj_ub > ($outdir & filename & ".out"); ", the script runs well. But if I don't comment out that line, AMPL will report the error message stated in my previous post.

Qie


reset;

option outdir "C:\Users\qhe\Documents\AMPL\switched_system\results\";

#turn off ampl presolve
option presolve 0;


option solver Baron;

option baron_options 'maxtime=600 objbound';

# include the following folders in the search path
option ampl_include ".\
.\instances";

model ss_minlp_general.mod;

set INSTANCES = {"n2_m10_K500_3","n2_m10_K500_4"};

for {filename in INSTANCES}{
    reset data;
    data (filename & ".dat");
    solve;

       
    if solve_result = "solved" then {
        display solve_result > ($outdir & filename & ".out");
        display l2norm_squared > ($outdir & filename & ".out");
        display _solve_time > ($outdir & filename & ".out");
        # record the best relaxation bound

        display l2norm_squared.obj_ub > ($outdir & filename & ".out");
        display z > ($outdir & filename & ".out");
        close ($outdir & filename & ".out");
    }       
}

To unsubscribe from this group and stop receiving emails from it, send an email to ampl+unsubscribe@googlegroups.com.

To post to this group, send email to am...@googlegroups.com.
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.



--
You received this message because you are subscribed to a topic in the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ampl/Vi0ayFJAf38/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ampl+unsubscribe@googlegroups.com.

AMPL Google Group

unread,
Jul 2, 2018, 6:04:41 PM7/2/18
to Ampl Modeling Language
Try defining

suffix obj_ub symbolic OUT;

The AMPL command processor does a preliminary parsing of a loop before any commands in the loop are executed; as a result, if you make a reference to .obj_ub in a loop, then the command processor may encounter .obj_ub before a "solve;" has had a chance to define it.

--
Dr. Paras Tiwari
am...@googlegroups.com
{#HS:612193683-12604#}
To unsubscribe from this group and stop receiving emails from it, send an email to ampl+uns...@googlegroups.com.

Qie He

unread,
Jul 3, 2018, 6:19:55 AM7/3/18
to am...@googlegroups.com
That works. Thanks a lot!

Qie

To unsubscribe from this group and stop receiving emails from it, send an email to ampl+unsubscribe@googlegroups.com.

To post to this group, send email to am...@googlegroups.com.
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.



--
You received this message because you are subscribed to a topic in the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ampl/Vi0ayFJAf38/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ampl+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages