[AMPL 24582] Selcting one value

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 (2.44 KB)

Sample.dat (390 Bytes)

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];