Do I need to add a constraint if I limit the variable indices?

  • 17 September 2021
  • 1 reply

Userlevel 1

In my model, I am tracking the production date of certain products. It is possible to produce a product at time t, while allocating it to demand on time t+3. However, there is a maximum ‘age’ of a product. For example ‘If a product is older that three days, it cannot be allocated’.


Now, given an allocation variable v_Allocate(i_Order, i_AllocationDay, i_Product, i_ProductionDay), indicating the allocation on day i_AllocationDay to order i_Order of i_Product which has production day i_Production day, I would like to restrict the index range to ‘valid’ combinations e.g. production day >= t-3. 


If I would restrict the index domain on the variable like so:

index domain: (i_Order, i_AllocationDay, i_Product, i_ProductionDay) | i_ProductionDay >= i_AllocationDay - 3


Do I still need to add a separate constraint to ensure this production day restriction?


In addition: does it make sense to do this in the index domain? 


Best answer by mohansx 21 September 2021, 04:41

View original

1 reply

Userlevel 5
Badge +5



Using index domain is a correct approach and is in fact more efficient than adding constraints to the model. 


You might want to also add i_ProductionDay <= i_AllocationDay condition to the index domain condition so that you avoid combinations of allocation products produced in the future to an order in the past. 


index domain: (i_Order, i_AllocationDay, i_Product, i_ProductionDay) | i_ProductionDay >= i_AllocationDay - 3 and i_ProductionDay <= i_AllocationDay


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

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