I have a set of 30 Customers, {1,2,...30}. I want to create subsets of these customers. Specifically, I want to get subsets with cardinality 1,2 and 3. These sets combined should then form the set ‘Routes’, such that the set ‘Routes’ looks as follows: {1}, {2}, … , {30}, {1,2}, {1,3},… { 29,30}, {1,2,3} , {1,2,4} ….. So the idea is to obtain routes containing 1,2 or 3 customers.
I would really appreciate some hints about implementing this in AIMMS.
Thank you in advance.
Best answer by deannezhang
Hi, I’m wondering if you just want to use all the 1-3 cardinality routes as the possible candidate routes to solve your optimization problem, or you want to list them for other reasons.
If it is the first case, you do not need to list all of them. The follow constraint will do the work:
sum(i, v_route(r,i)) <= 3, for all r
r is the index for your resulting route, and i is a customer. v_route(r,i) is 1 if customer i is in route r, and the total number of customers in a route does not exceed 3.
Hi, I’m wondering if you just want to use all the 1-3 cardinality routes as the possible candidate routes to solve your optimization problem, or you want to list them for other reasons.
If it is the first case, you do not need to list all of them. The follow constraint will do the work:
sum(i, v_route(r,i)) <= 3, for all r
r is the index for your resulting route, and i is a customer. v_route(r,i) is 1 if customer i is in route r, and the total number of customers in a route does not exceed 3.
Hope that the@deannezhang suggestion have worked for your optimization problem. However, I also developed the ‘Route’ set exaclty how you were wondering to develop.
empty s_calc_combinatedData;
!add for #1 for INIT do SetElementAdd(s_calc_combinatedData, pe_calc_combinatedData, INIT); endfor;
!add for #2 for (INIT,INIT_AUX1) | ord(INIT) < ord(INIT_AUX1) do ps_loc_newElement := FormatString("%e - %e", INIT, INIT_AUX1);