Constraint with present and next time state

Problems with modeling
gmud774
User Posts: 4
Joined: 1 year ago

Constraint with present and next time state

Hi,
I am trying to write these constraints in my model:

Soc_limitu(i) .. Soc_start- Pch(i) + Pdch(i) =L= Soc_max;
Soc_limitl(i) .. Soc_start- Pch(i) + Pdch(i) =G= Soc_min;

where Soc_start is a scalar with a constant value but its value is used at the start only for i=1, after that from 2 to 24, Soc_start(i+1)=Soc_start(i)- Pch(i) + Pdch(i) as for Soc_start(2)=Soc_start(1)- Pch(1) + Pdch(1) for i=2 and so but I am unable to write this formulation. Can anyone help me please!

Thank You so much.

Kind regards,
Mohyuddin
UOW Australia

bussieck
Moderator Posts: 328
Joined: 2 years ago

Re: Constraint with present and next time state

You should check the documentation for lag and lead: https://www.gams.com/latest/docs/UG_Ord ... dOperators

-Michael

gmud774
User Posts: 4
Joined: 1 year ago

Re: Constraint with present and next time state

Thank you so much Michael.

In lag or lead the variable should be a vector, here I am calculating the value on every interval i=1:24 and it is updated on every interval with a one value given at the start. So If anyone can help me in making logic for this.
In this equations:
Soc_start is scalar assigned a value at the start.
Soc_limitu(i) .. Soc_start- Pch(i) + Pdch(i) =L= Soc_max;
Soc_limitl(i) .. Soc_start- Pch(i) + Pdch(i) =G= Soc_min;
after i=1, it should be,
Soc=Soc_start- Pch(i) + Pdch(i) ;
and Soc_start=Soc; before going to the next iteration for i=2, How can I make this logic? can anyone help with this!

I am extremely thankful.

Kind regards,
Mohyuddin
UOW Australia

Renger
Posts: 268
Joined: 2 years ago

Re: Constraint with present and next time state

Hi Mohyuddin

If you make soc_start a variable over the set i and fix it for the first i:

Code: Select all

``````variable Soc(i);
Soc_limitu(i) ..  Soc(i) - Pch(i) + Pdch(i) =L= Soc_max;
Soc_limitl(i) ..   Soc(i) - Pch(i) + Pdch(i) =G= Soc_min;
Soc_mov(i)..    Soc(i+1) =E= Soc(i) - Pch(i) + Pdch(i)

* We fix the first value to the startvalue
So("i1") = startvalue;
``````
Cheers
Renger

gmud774
User Posts: 4
Joined: 1 year ago

Re: Constraint with present and next time state

Dear Sir,

Thank you so much.

Kind regards,
Mohyuddin
UOW Australia