Skip to main content
Solved

Subtraction of Element Valued Expressions

  • May 29, 2019
  • 9 replies
  • 228 views

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?

Best answer by deannezhang

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

9 replies

deannezhang
AIMMS Champ
Forum|alt.badge.img+3
  • AIMMS Champ
  • 61 replies
  • Answer
  • May 29, 2019
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

  • Author
  • Newcomer
  • 9 replies
  • May 29, 2019
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

?

deannezhang
AIMMS Champ
Forum|alt.badge.img+3
  • AIMMS Champ
  • 61 replies
  • May 30, 2019
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.

  • Author
  • Newcomer
  • 9 replies
  • May 30, 2019
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


deannezhang
AIMMS Champ
Forum|alt.badge.img+3
  • AIMMS Champ
  • 61 replies
  • May 30, 2019
what does ": " mean?

  • Author
  • Newcomer
  • 9 replies
  • May 30, 2019
it’s “for which”

deannezhang
AIMMS Champ
Forum|alt.badge.img+3
  • AIMMS Champ
  • 61 replies
  • May 30, 2019
😂care for some more explanation on the meaning of the constraint and index? otherwise, I do not know how to help here.

  • Author
  • Newcomer
  • 9 replies
  • May 30, 2019
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

deannezhang
AIMMS Champ
Forum|alt.badge.img+3
  • AIMMS Champ
  • 61 replies
  • May 31, 2019
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))


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

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