Hi dear community,
I’m trying to add this subtour elimination constraint into my AIMMS project.
sum( (k,l) | k<>l and k in SubsetofLocations and l in SubsetofLocations, y(b,k,l)) <= |SubsetofLocations| - 1
where y(b,k,l) = 1 indicating the picker will go from location k to location l while picking items in batch b.
My questions are:
- How can I generate all of the subsets that are required to be used here? I checked the TSP example on AIMMS website and it seems like these subsets are generated automatically? If it’s not, how should I set it up?
- How can I get the number of locations in a subset(the |SubsetofLocations|) when it is generated everytime?
- I want to add this as a lazy constraint with the callback function. But I’ve been quite lost about how to set it up. I know how to add it in the MainExecution (I just followed the TSP example) but I’m not quite sure about what else will I need. Should I just ignore the entire “Declaration Network” part(since I don’t need to show the routes) and copy the “CB_Lazy(ThisSession)” , “DetermineSubtours(ThisSession)”, “ResetCase” into my project?
I’m quite new to AIMMS so any help will be appreciated!
Best answer by Chris Kuip
- All subsets of a given set can be created using a simple loop, as illustrated in the attached example. I assume you are aware that there are exponentially many subsets of a set.
- You can use the card function, see AIMMS The Function Reference for details.
- Indeed, using a lazy constraint is the way to go.
The declaration section "declaration network“ is for display purposes only and can be ignored if you are interested in the algorithm itself.
On the other hand, the
DetermineSubtoursprocedures are essential to the algorithm.