set FOODS; set FOOD_TYPES; set FOOD_GROUP {FOOD_TYPES} within FOODS;
set FOODS := a b c d e f g h i j ; set FOOD_TYPES := vegetables fruits sides staples ; set FOOD_GROUP[vegetables] := a b c ; set FOOD_GROUP[fruits] := d e ; set FOOD_GROUP[sides] := f ; set FOOD_GROUP[staples] := g h i j;
subject to MinRatio {ft in FOOD_TYPES, t in T}: sum {f in FOOD_GROUP[ft]} R[f,t] >= minrat[ft];
Do you mean the word document or ampl.mod? Here is the word document.
On Fri, Dec 22, 2023 at 8:25 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Hi, Sure i can help. Can you send me the doc file instade of those screenshots
Then, how to write the parameter of minrat and maxrat. Would you mind give me some examples please ?
On Tue, Dec 26, 2023 at 10:12 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
I am guessing that a "food" and a "commodity" are the same thing in your description. You could set up the food groups like this:set FOODS; set FOOD_TYPES; set FOOD_GROUP {FOOD_TYPES} within FOODS;
Then the data would look something like this (where just for this example, I have used some arbitrary letters for the food names):set FOODS := a b c d e f g h i j ; set FOOD_TYPES := vegetables fruits sides staples ; set FOOD_GROUP[vegetables] := a b c ; set FOOD_GROUP[fruits] := d e ; set FOOD_GROUP[sides] := f ; set FOOD_GROUP[staples] := g h i j;
Your "minrat" constraint could then be written like this (after T, R, and minrat are defined appropriately):subject to MinRatio {ft in FOOD_TYPES, t in T}: sum {f in FOOD_GROUP[ft]} R[f,t] >= minrat[ft];

Robert Fourer
We're switching to a new, enhanced user forum.
Join it now at discuss.ampl.com.
can ampl solve the multiobjective? minimize and maximize?
On Wed, Dec 27, 2023 at 5:36 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
To test my example, I added these definitions:
set T;
param minrat {FOOD_TYPES};
var R {FOODS,T} >= 0;
Then I made up some test data for T and minrat.

Robert Fourer
We're switching to a new, enhanced user forum.
Join it now at discuss.ampl.com.
what about the preemptive method in ampl? how to solve it when it has multiobjectives?
im so sorry. To make me understand better, can you give me some examples?
On Thu, Jan 4, 2024 at 3:11 AM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
ok, thank you Robert. I will try that.
On Wed, Jan 3, 2024 at 1:20 AM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
If you use .objpriority (rather than .objweight) then you get a preemptive method:The procedure continues in this way until all objectives have been considered.
 The solver first solves with the objective that has the highest priority.
 Then the solver fixes the highestpriority objective to its optimal value, and solves with the objective that has the secondhighest priority.
 Then the solver fixes the secondhighestpriority objective to its optimal value, and solves with the objective that has the thirdhighest priority.

Robert Fourer
We're switching to a new, enhanced user forum.
Join it now at discuss.ampl.com.
what if i have three objective functions and the third is about maximizing?
On Sat, Jan 6, 2024 at 1:15 AM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
To run the attached example using Gurobi as the solver, execute "include diet.run" in AMPL. The model (diet.mod) has two objective functions, Total_Cost and Total_Vit_C:
minimize Total_Cost: sum {j in FOOD} cost[j] * Buy[j];
maximize Total_Vit_C: sum {j in FOOD} amt["C",j] * Buy[j];
In diet.run, Total_Cost is set to have a higher priority:
suffix objpriority IN;
let Total_Cost.objpriority := 2;
let Total_Vit_C.objpriority := 1;
Then Gurobi is set up for multiobjective optimization, and is invoked with a "solve" command:
option solver gurobi;
option gurobi_options 'multiobj=1';
solve;
Gurobi minimizes the higher priority objective (Total_Cost) first. Then it fixes Total_Cost at its optimal value, and maximizes the lowerpriority objective (Total_Vit_C). The resulting solution is returned to AMPL, where you can view it:
display Total_Cost, Total_Vit_C;
display Buy;

Robert Fourer
We're switching to a new, enhanced user forum.
Join it now at discuss.ampl.com.
oke, i got it. Thank you Robert
On Tue, Jan 9, 2024 at 4:15 AM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:What does it mean?
The let command cannot assign to nutrient_value_score.
context: let nutrient_value_score := >>> 1; <<<
Gurobi 10.0.1: Gurobi 10.0.1: optimal solution; objective 579486.6704
20 simplex iterations
1 branching nodes
Objective = total_cost
total_cost = 579487
kilocalories = 19982.5
nutrient_value_score = 99.7933
On Mon, Jan 8, 2024 at 11:23 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
It works the same way with three objective functions. In your model, use an AMPL "minimize" or "maximize" statement to define each of the three objective functions. Then assign a different priority to each of the three objective functions, using .objpriority as shown in my example.
Solving with Gurobi is then also the same as in my example. Also the same setup works with CPLEX, using
option solver cplex;
option cplex_options 'multiobj=1';

Robert Fourer
We're switching to a new, enhanced user forum.
Join it now at discuss.ampl.com.
#SHOW RESULTS
display total_cost, kilocalories, nutrient_value_score;
display ratio_commodity;
ampl: Gurobi 10.0.1: Gurobi 10.0.1: optimal solution; objective 61571.80715
23 simplex iterations
1 branching nodes
absmipgap=1.45519e11, relmipgap=0
Objective = total_cost
total_cost = 61571.8
kilocalories = 1400
nutrient_value_score = 100
Hi, what does it mean? Can you fix it?
#SHOW RESULTS
display total_cost, kilocalories, nutrient_value_score;
display ratio_commodity;
ampl: Gurobi 10.0.1: Gurobi 10.0.1: optimal solution; objective 61571.80715
23 simplex iterations
1 branching nodes
absmipgap=1.45519e11, relmipgap=0
Objective = total_cost
total_cost = 61571.8
kilocalories = 1400
nutrient_value_score = 100
On Tue, Jan 9, 2024 at 8:35 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
Is nutrient_value_score the name of an objective function (from a "minimize" or "maximize" statement in your model)? If you try to use a "let" statement to assign a value to an objective function, then you will get an error message like the one you see. AMPL always computes the value of an objective automatically, from the current values of the variables.
If nutrient_value_score is not an objective function, then can you show the complete definition of nutrient_value_score from your model? With that information, it will be possible to give you more help.

Robert Fourer
We're switching to a new, enhanced user forum.
Join it now at discuss.ampl.com.


Available Time for Contact: Saturday  Not available. Sunday  Not available. Monday  11:00 AM to 12:00 PM and 1:00 PM to 3:00 PM, (UK + Time Zone) Tuesday  12:00 PM to 2:00 PM, (UK + Time Zone) Wednesday  12:00 PM to 2:00 PM, (UK + Time Zone) Thursday  12:00 PM to 2:00 PM, (UK + Time Zone) Friday  12:00 PM to 2:00 PM, (UK + Time Zone) Contact Number: +4407915302721 Email: ijtih...@gmail.com 

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.
To view this discussion on the web visit https://groups.google.com/d/msgid/ampl/85cc1b53c8304affba19cd6dca1f9ff0n%40googlegroups.com.
option solver gurobi; option gurobi_options 'sol:stub=bestgurobi sol:poolmode=2 sol:poollimit=5'; solve; for {i in 1..Total_Cost.npool} { solution ("bestgurobi" & i & ".sol"); # put commands to display or process each solution here }
can ampl show the top 5 solutions for each objective function. If it yes, how to write in the running script?
On Fri, Jan 19, 2024 at 7:40 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:Let me try
Ijtihad Emon BBA, (Notre Dame University of Bangladesh) MSc.Business Analytics (University of Kent), UK
+447915302721  ijtih...@gmail.com
UK, Canterbury
Please make sure to maintain the time available for a contact.
Available Time for Contact:
Saturday  Not available.
Sunday  Not available.
Monday  11:00 AM to 12:00 PM and 1:00 PM to 3:00 PM, (UK + Time Zone)
Tuesday  12:00 PM to 2:00 PM, (UK + Time Zone)
Wednesday  12:00 PM to 2:00 PM, (UK + Time Zone)
Thursday  12:00 PM to 2:00 PM, (UK + Time Zone)
Friday  12:00 PM to 2:00 PM, (UK + Time Zone)
Contact Number: +4407915302721
Email: ijtih...@gmail.com
On Fri, Jan 19, 2024 at 7:33 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
For a mixedinteger program, the solver has proved optimality when the gap between the lower bound and the upper bound is 0. However, to avoid extra work that makes only a very minor improvement, Gurobi may stop when the absolute gap (absmipgap) or the gap relative to the size of the solution (mipgap) is "small enough".
In your example, the absmipgap is such a tiny number (1.45519e11) that you should consider it to be the same as 0. Thus you should consider the solution returned by Gurobi to be optimal (and there is nothing that needs to be fixed).
On Fri, Jan 19, 2024 at 6:33 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Hi, what does it mean? Can you fix it?
#SHOW RESULTS
display total_cost, kilocalories, nutrient_value_score;
display ratio_commodity;
ampl: Gurobi 10.0.1: Gurobi 10.0.1: optimal solution; objective 61571.80715
23 simplex iterations
1 branching nodes
absmipgap=1.45519e11, relmipgap=0
Objective = total_cost
total_cost = 61571.8
kilocalories = 1400
nutrient_value_score = 100
On Tue, Jan 9, 2024 at 8:35 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
Is nutrient_value_score the name of an objective function (from a "minimize" or "maximize" statement in your model)? If you try to use a "let" statement to assign a value to an objective function, then you will get an error message like the one you see. AMPL always computes the value of an objective automatically, from the current values of the variables.
If nutrient_value_score is not an objective function, then can you show the complete definition of nutrient_value_score from your model? With that information, it will be possible to give you more help.

Robert Fourer
We're switching to a new, enhanced user forum.
Join it now at discuss.ampl.com.