Selcting one value

3 views
Skip to first unread message

Matts Davids

unread,
Mar 21, 2023, 5:51:32 AM3/21/23
to am...@googlegroups.com
Hello sir,

I am running an optimization problem with a goal to minimize the operation cost of a shop. I would like to reduce the Pg_Peak by adding a penalty factor such as C_peak*PgPeak. However, I am struggling to write a line that identifies Pg_peak which is the maximum value among the values of the variable Pg. Can someone help me to fix it?

attached are my lines.

Sincerely;
Davids

Sample.mod
Sample.dat

AMPL Google Group

unread,
Mar 21, 2023, 1:02:58 PM3/21/23
to AMPL Modeling Language
You can't do this with a "for{t in TT}" loop and a "let". Instead, add a constraint that says Pg_peak is greater than or equal to Pg[t] for all members of set TT:

subject to PeakDefinition {t in TT}: Pg_peak >= Pg[t];


--
Robert Fourer

We're switching to a new, enhanced user forum.
Join it now at discuss.ampl.com.
{#HS:2189831386-115216#}
Reply all
Reply to author
Forward
0 new messages