iterative issue Topic is solved

Problems with modeling
Post Reply
erre_nebu
User
User
Posts: 12
Joined: 3 years ago

iterative issue

Post by erre_nebu »

Hi there, i want to do the following thing, but i think i'm doing it in the wrong way.

so i want to perform a 24h simulation over, lets say, three days.

so i wrote

set
day /d1*d3/
time /t1*t24/
itday(day,time) /#day.#time/
oday(time)
dummy /x1*x5/

parameters
par(day,dummy,time)
...

variables
var(day, dummy,time)
...

equations
equ(day,dummy,time)
...

list of equations;
equ(day,dummy,time)$oday(time)...

...
alias(day,iter)
loop(iter,
oday(time) = itday(iter,time);
solve.... ;

list of parameters used as new input for next day....

);

so i thought i would have obtained results as a form of d1 for first optimization, d2 for second and so on.

however, if i open the .lst file in the "equation" part i see both the calculation for day one and day two in both the list (see picture), that is not what i wanted to obtain.
image.png
image.png (4.41 KiB) Viewed 3105 times
any suggestion?
abhosekar
Moderator
Moderator
Posts: 295
Joined: 3 years ago

Re: iterative issue

Post by abhosekar »

I am not sure if I understand this correctly but it looks to me that you are using an if condition on time.
To have equations separate based on the days, you may need to use an if condition on day. $subset(day)

equ(day,dummy,time)$oday(time)
It is natural that this equation has d1 and d2 both as the condition is not on day.

Seconly, you may want to deactivate the set element after solve at the end of each iteration.
subset(day) = yes;
solve statement
subset(day) = no;

If you don't include "=no" statement, in the next iteration, both d1 and d2 will be active and all the equations will be included.

Hope this helps.

- Atharv
erre_nebu
User
User
Posts: 12
Joined: 3 years ago

Re: iterative issue

Post by erre_nebu »

dear Atharv,

if i move from oday(time) to oday(day) i receive the error "Uncontrolled set entered as constant".

even if i add the yes/no sentences, nothing different happens.


if i remove the sentence oday(iter) = itday(iter,t) the simulation starts but with the same initial issue.
Attachments
image.png
image.png (5.64 KiB) Viewed 3078 times
abhosekar
Moderator
Moderator
Posts: 295
Joined: 3 years ago

Re: iterative issue

Post by abhosekar »

You get uncontrolled set warning for the line
oday(day)= no;

This statement is not needed and should be removed.
because outside the loop, day is not defined.

Hope this helps.

- Atharv
erre_nebu
User
User
Posts: 12
Joined: 3 years ago

Re: iterative issue

Post by erre_nebu »

Dear Atharv,

thx a lot. it worked.
Post Reply