Solved

use of If-Then-Constraint

  • 20 October 2021
  • 7 replies
  • 284 views

Badge +3

 Good morning all,

Please, can someone tell me why I keep getting this error :point_down_tone4:? Both SOC(agg,t) and P_Charging(agg,t) are variables.

Thanks so much.

 

 

icon

Best answer by mohansx 20 October 2021, 23:08

View original

7 replies

Userlevel 5
Badge +5

@olusegun.adeniji 

 

The problem is with your “else” block. This is a constraint and not a variable definition, so 

else

P_Charging(agg, t)

endif

does not make any sense. You can simply have

 

IF SOC(agg, t-1) > 0.949 THEN

P_Charging(agg, t) = 0

ENDIF

Userlevel 5
Badge +5

@olusegun.adeniji In that case, instead of upper limit U2, you use the lower limit of P_Charging with range [L2, 0].

P_Charging(agg, t) <= 0 + U2 * (1 - Y(agg, t))

will become something like

P_Charging(agg, t) >= L2 * (1 - Y(agg, t))

 

When Y is 0, this will be P_Charging >= L2 and when Y = 1 - P_Charging >= 0 which will force it to be P_charging = 0 because of the range L2 <= P_Charging <= 0

Badge +3

Thanks @mohansx for your response.

Badge +3

Thanks @mohansx ,

I tried that suggestion and  it still gives error of missing “ELSE” part. Sincerely this looks so simple to tackle personally considering what I have done in AIMMS but I really dont know why I cant resolve it. Any further help would be greatly appreciated.

 

Thanks

 

Userlevel 5
Badge +5

Hello @olusegun.adeniji 

 

Apologies, I missed that AIMMS requires IF blocks in constraints to have ELSE conditions too. 

 

You have two options -

 

  1. Create another variable with same index domain as P_Charging(agg, t), call is temp_Charging(agg, t). Give it the below definition

    IF SOC(agg, t-1) > 0.949 THEN

    0

    ELSE

    P_Charging(agg, t)

    ENDIF


    Use temp_Charging(agg, t) in the objective function or other constraints/definitions instead of P_Charging.
  2. Use the modelling trick described in section 7.4 of the AIMMS Optimization Modelling guide.

    Your requirement is SOC(agg, t-1) > 0.949, then P_Charging(agg, t) must be 0 → which is equivalent to only one of SOC(agg, t-1) <= 0.949 and P_Charging(agg, t) <= 0 can be true. 

    use a binary variable Y(agg, t) and upper limits for SOC - U1 and upper limit for P_Charging - U2. Introduce two constraints with index domain (agg, t)

    constraint1



    SOC(agg, t-1) <= 0.949 + U1 * Y(agg, t)



    constraint2



    P_Charging(agg, t) <= 0 + U2 * (1 - Y(agg, t))

If SOC(agg, t-1) needs to be greater than 0.949, Y(agg, t) must be 1 which will force the second constraint to become P_Charging(agg, t) <= 0 + 0 = 0 (assuming the range of P_Charging is nonnegative). 

I hope this helps.

Badge +3

Hello @mohansx ,

Thanks for your response. My system went for some maintenance and just returned with it. I will let you know if your suggestion solves my problem.

Thanks again

Olusegun

Badge +3

Hi @mohansx ,

Sorry to bother you again on the above subject. 

Please I want to ask what happens if range of P_Charging is nonpositive, that is it must be negative or zero?

Please, what will now be U2?

Thanks in advance for your prompt response.

Olusegun

Reply


Didn't find what you were looking for? Try searching on our documentation pages:

AIMMS Developer & PRO | AIMMS How-To | AIMMS SC Navigator