Solved

If statement in constraint

  • 2 December 2019
  • 2 replies
  • 375 views

Hi dear community,

 

I have a constraint as sum((k,z1), y(b,k,z1,l,z2)) <= 1 and I want to add if statement to it:

if k = l, then z1 cannot be equal to z2;

if k<>l, then there’s no further constraint for z1 and z2.

I tryed to add it like this:

if k<>l then sum((k,z1), y(b,k,z1,l,z2)) <= 1
endif;
if k=l then sum((k,z1)|z1<>z2, y(b,k,z1,l,z2)) <= 1
endif;

The AIMMS through out the message “The scope of index "k" has not been specified.” like shown in the screenshot(I’ve highlighted where the error is-the first k appears in if statement).

So my question is, is there a way to fix this constraint in the way that I want it to be? (maybe using element parameter)?

 

Thanks in advance!

icon

Best answer by Marcel Hunting 2 December 2019, 13:42

View original

2 replies

Hi @lin86 

Were you able to find a solution to your problem? Or was Marcel’s answer sufficient in helping you with your problem?

Best Regards

Userlevel 4
Badge +4

Do you get what you want if you use the following definition?

 

sum((k,z1) | k<>l, y(b,k,z1,l,z2))

+

sum(z1 | z1<>z2, y(b,l,z1,l,z2))

<=

1

Reply


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

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