Skip to main content
Hi! I have a constraint (shown at the photo below) wherein two sets need to be subtracted. I tried introducing another set Kw with a definition of k-Ks but it says subtraction of element valued expressions require the set range to be equal, but the ranges domain set "Subblock" and set "Candidate_Subblocks" differ.



Identifier: Subblock

Index: k



Identifier: Candidate_Subblock

Index: Ks



Identifier: Subblock_Difference

Subset of: Subblock, Candidate_Subblocks

Index: Kw

Definition: k-Ks



above is the current code I have. Do you have any Idea on how I can code my constraint?

If Tv is input, which means it does not change depending on variables, what you can do is to introduce parameter As Tv. For example, Valid_v_t(v,t) is 1 if vessel v can load/unload at time t. then (7) can be something like



Identifier: constraint7



index domain: (k,t)



definition: gamma(k,t) = sum(v|Valid_v_t(v,t) , x(v,k))
Constraint 7:



YL(k,t) - Binary Variable(set to 1 if subblock k executes loading activity in period t)

x(v,k) - Binary variable(1 if subblock K is reserved for vessel V)

Tv - subset of period/s when vessel v loads or unloads containers



constraint 7: denotes whether a subblock performs a loading/unloading activity
😂care for some more explanation on the meaning of the constraint and index? otherwise, I do not know how to help here.
it’s “for which”
what does ": " mean?
Thank you! I have one last question,



how do I code constraint 7 and 9? Cause I’m not quite sure with the “:” in it. Sorry! Thank you


sum(Kw, x(v,kw))=0 will work.



you can use the index of the subset so it will only apply those elements in the subset.
Thank you so much! It worked! Now my constraint will be written



sum(Kw, x(v,k))=0



or



sum[(k|Kw, x(v,k))] = 0



?
Making both Candidate_Subblock and Subblock_Difference as a subset of Subblock and change the definition of Subblock_Difference like below should work.



Identifier: Subblock

Index: k



Identifier: Candidate_Subblock

Subset of: Subblock

Index: Ks



Identifier: Subblock_Difference

Subset of: Subblock

Index: Kw

Definition: Subblock - Candidate_Subblock

Reply


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

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