[AMPL 16069] Conditional operators in constraints

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[AMPL 16069] Conditional operators in constraints

Juan Zhang
I am trying to implement the following, and I am getting a syntax error.

subject to ST_Cost {i in GENERATORS, t in TIME}:
if t == 1 then
C_SU[i, t] >= GenData['K', i] * (I[i, t] - GenData['INI', i]);
else
{
C_SU[i, t] >= GenData['K', i] * (I[i, t] - I[i, t-1]);
}
;

I have also tried the following with no success:

subject to ST_Cost {i in GENERATORS, t in TIME}:
t == 1 ==>          C_SU[i, t] >= GenData['K', i] * (I[i, t] - GenData['INI', i])       else      C_SU[i, t] >= GenData['K', i] * (I[i, t] - I[i, t-1]);

Does anyone have any pointers?

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [AMPL 16074] Conditional operators in constraints

AMPL mailing list
Following should work:

subject to ST_Cost {i in GENERATORS, t in TIME}:
C_SU[i, t] >=
if t == 1 then
GenData['K', i] * (I[i, t] - GenData['INI', i])
else
GenData['K', i] * (I[i, t] - I[i, t-1]);

--
Paras Tiwari
[hidden email]
{#HS:553179379-4319#}
On Mon, Apr 2, 2018 at 6:26 PM UTC, <[hidden email]> wrote:
I am trying to implement the following, and I am getting a syntax error.

subject to ST_Cost {i in GENERATORS, t in TIME}:
if t == 1 then
C_SU[i, t] >= GenData['K', i] * (I[i, t] - GenData['INI', i]);
else
{
C_SU[i, t] >= GenData['K', i] * (I[i, t] - I[i, t-1]);
}
;

I have also tried the following with no success:

subject to ST_Cost {i in GENERATORS, t in TIME}:
t == 1 ==> C_SU[i, t] >= GenData['K', i] * (I[i, t] - GenData['INI', i]) else C_SU[i, t] >= GenData['K', i] * (I[i, t] - I[i, t-1]);

Does anyone have any pointers?
--
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 [hidden email].
To post to this group, send email to [hidden email].
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 the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.