Can I put 2 objective functions in 1 model

119 views
Skip to first unread message

huan...@gmail.com

unread,
May 19, 2007, 6:20:41 PM5/19/07
to AMPL Modeling Language
Hello

I need two objective funcitons in one model, and I need to choose them
in the run file.
Is there a way to do that?

Rodrigo Lopez-Negrete

unread,
May 20, 2007, 3:31:55 PM5/20/07
to AMPL Modeling Language
Sure you can using named problems.

check out http://ampl.com/NEW/loop2.html

hth,
Rodrigo

Robert Fourer

unread,
May 21, 2007, 1:17:26 AM5/21/07
to am...@googlegroups.com, huan...@gmail.com, Rodrigo Lopez-Negrete

You can also use the "objective" command to change the choice of objective,
if you have defined more than one objective in the model. I have previously
used the attached example in my class notes:

ampl: model diet1obj.mod;
ampl: data diet1lim.dat;
ampl: option solver cplex;

With the given data, a solution can be found to minimize total costs:

ampl: objective TotalCost;
ampl: solve;

CPLEX 10.1.0: optimal integer solution; objective 16.52
87 MIP simplex iterations
30 branch-and-bound nodes

ampl: display TotalCost, TotalNutr['Cals'];
TotalCost = 16.52
TotalNutr['Cals'] = 3350

Or the objective can be changed to one that minimizes total calories:

ampl: objective TotalNutr['Cals'];
ampl: solve;

CPLEX 10.1.0: optimal integer solution; objective 3195
35 MIP simplex iterations
9 branch-and-bound nodes

ampl: display TotalCost, TotalNutr['Cals'];
TotalCost = 17.84
TotalNutr['Cals'] = 3195

If no objective is specified, then the the first one is chosen by default.

Bob Fourer
4...@ampl.com

diet1obj.mod
diet1lim.dat

h...@uark.edu

unread,
May 21, 2007, 11:36:42 AM5/21/07
to AMPL Modeling Language
See also an AMPL implementation of multiple objective functions to
Goal Proramming in Taha, Operations Research: An Introduction, 8th ed,
Prentice Hall 2007, pp. 345-346, http://taha.ineg.uark.edu/

On May 19, 5:20 pm, huang...@gmail.com wrote:

Reply all
Reply to author
Forward
0 new messages