Hi Andrés,
I think you still forgot to use the "let"-statement. You habe to use "let" to allocate data during runtime.
Best regards,
Lothar
On Tue, Jun 13, 2023 at 10:49 AM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Hi Lothar, thank you very much for answer me.
It doesnt work :(
syntax error
context: if L[l,s]>=K[l,s] then >>> DL[l,s]:= <<< L[l,s] else let
DL[l,s]=0;
On Tue, Jun 13, 2023 at 6:22 AM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Hi Andrés,
you have to use the "let" statement allocating data to a parameter or
indipendend variable. Also ":=" instead of "=" Thus, the correct syntax is
(maybe I am using to many brackets ;) ):
if (L[l,s]>=K[l,s]) then {let DL[l,s]:=L[l,s];} else {let DL[l,s]:=0;}
Regards,
Lothar
Andrés schrieb am Montag, 12. Juni 2023 um 18:59:46 UTC+2:
set Lset;
set Sset;
var L {Lset,Sset};
var K {Lset,Sset};
var DL {l in Lset, s in Sset} =
if L[l,s] > K[l,s] then L[l,s] else 0;set Lset;
set Sset;
var L {Lset,Sset};
var K {Lset,Sset};
var DL {l in Lset, s in Sset};
minimize testobj:
sum {l in Lset, s in Sset} DL[l,s];
subject to setDL {l in Lset, s in Sset}:
L[l,s] > K[l,s] ==> DL[l,s] = L[l,s] else DL[l,s] = 0;Hi, It's me again... jajaja
Sorry for insist...
On Tue, Jun 13, 2023 at 4:42 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
As this?
let
DL[l, s] = L[l,s] if L[l,s]>K[l,s] else 0;
Thank you
On Tue, Jun 13, 2023 at 4:34 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
For this case:
DL[l, s] = if ... then L[i, s] else 0; # the else part can be
omitted if 0
In general:
<condition> ==> <constraint 1> [else <constraint 2>];
See https://amplmp.readthedocs.io/en/latest/rst/model-guide.html.
On Tue, Jun 13, 2023 at 2:48 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
First, thank you (both) very much for your valuable time and help.
Lothar:
The AMPL output is as follows:
conditional.mod, line 142 (offset 5855):
let is not defined
context: if (L[l,s]>=K[l,s]) then {let >>> DL[ <<< l,s]:=L[l,s];} else {let DL[l ,s]:=0;}
Something is wrong with "let"
Robert:
1) L, K and DL are variables. In fact, DL is a construction from L, as long as it is not a value equal to K. I mean, DL[l,s] is constructed from the values of L[l,s] that are greater than the values of K[l,s]. In the rest of the positions where it is not fulfilled, it must be filled with 0.
2) It is not properly a restriction. DL for me, is an auxiliary variable that is built from L and K.
Andrés
On Tue, Jun 13, 2023 at 2:26 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
It is not clear what you are trying to do with this statement. Can you provide some additional information?
- First, show your model's definitions of L, K, and DL, so that it is clear which ones are parameters (data) and which are decision variables.
- Then, explain whether "if L[l,s]>=K[l,s] then DL[l,s]=L[l,s] else DL[l,s]= 0;" is supposed to be a constraint in your model, or whether it is just an assignment of values to parameter DL.
--
Robert Fourer
We're switching to a new, enhanced user forum.
Join it now at discuss.ampl.com.
On Tue, Jun 13, 2023 at 11:15 AM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Hi Andrés,
I think you still forgot to use the "let"-statement. You habe to use "let" to allocate data during runtime.
Best regards,
Lothar
On Tue, Jun 13, 2023 at 10:49 AM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Hi Lothar, thank you very much for answer me.
It doesnt work :(
syntax error
context: if L[l,s]>=K[l,s] then >>> DL[l,s]:= <<< L[l,s] else let
DL[l,s]=0;
On Tue, Jun 13, 2023 at 6:22 AM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Hi Andrés,
you have to use the "let" statement allocating data to a parameter or
indipendend variable. Also ":=" instead of "=" Thus, the correct syntax is
(maybe I am using to many brackets ;) ):
if (L[l,s]>=K[l,s]) then {let DL[l,s]:=L[l,s];} else {let DL[l,s]:=0;}
Regards,
Lothar
Andrés schrieb am Montag, 12. Juni 2023 um 18:59:46 UTC+2: