counter to calculate on and off time

14 views
Skip to first unread message

AbdeRahman Mostafa

unread,
Jul 8, 2022, 2:44:30 AM7/8/22
to AMPL Modeling Language
i want to create a counter for the time how long unit is off and a counter for a time how long unit is off, i have three binary variables status, on status and off status
I tried with repeat but syntax error always coming, i tried with for loop ,no errors, but when i checkthe value  display x_gen_on,it shows #empty
can some one help me


param x_gen_on{s in SCN, g in MPC_GEN_ID, t in TME} default 0  ;
for{s in SCN, g in MPC_GEN_ID, t in TME}{
     if V_Gen_Startup[s,g,t]==1
     then let x_gen_on[s,g,t]:=x_gen_on[s,g,t] + 1;
     else if V_Gen_Status[s,g,t]==1 then continue;
     else if V_Gen_shutdown[s,g,t]==1 then break;
   }
  

AMPL Google Group

unread,
Jul 10, 2022, 12:41:53 AM7/10/22
to AMPL Modeling Language
AMPL shows "# empty" when displaying an empty set. So I would not normally expect to see "# empty" when displaying the value of param x_gen_on.

Can you give a complete example, which shows the error message when it is run in AMPL? Then it should be possible to determine what the error is and how it can be fixed.


--
Robert Fourer
am...@googlegroups.com
{#HS:1943383314-110904#}
On Fri, Jul 8, 2022 at 6:44 AM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
i want to create a counter for the time how long unit is off and a counter for a time how long unit is off, i have three binary variables status, on status and off status

I tried with repeat but syntax error always coming, i tried with for loop ,no errors, but when i check the value display x_gen_on,it shows #empty

AbdeRahman Mostafa

unread,
Jul 11, 2022, 1:40:18 AM7/11/22
to AMPL Modeling Language
Dear Robert
There is no error showing but when i display x_gen_on,it shows #empty, so is there better method to code an counter for the number of times unit is on, other than what i wrote  as i think AMPL not compiling it

AMPL Google Group

unread,
Jul 11, 2022, 2:12:17 AM7/11/22
to AMPL Modeling Language
It is not possible to give an answer based only on the statements you have shown. To get help with this issue, you will need to provide a complete example.

Your example should include all of the AMPL model and data statements that you are running, up to the point where the "# empty" message is displayed. You can attach model and data files, or copy the contents of the files into your reply.


--
Robert Fourer
am...@googlegroups.com
{#HS:1943383314-110904#}
On Mon, Jul 11, 2022 at 5:40 AM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Dear Robert
There is no error showing but when i display x_gen_on,it shows #empty, so is there better method to code an counter for the number of times unit is on, other than what i wrote as i think AMPL not compiling it

On Sun, Jul 10, 2022 at 4:41 AM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
AMPL shows "# empty" when displaying an empty set. So I would not normally expect to see "# empty" when displaying the value of param x_gen_on.

Can you give a complete example, which shows the error message when it is run in AMPL? Then it should be possible to determine what the error is and how it can be fixed.


--
Robert Fourer
am...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages