Skip to main content

Hey everyone,

I'm working on a vehicle routing problem (VRP) project where the routing will involve more than one company, and customers may have orders from more than one company. So, the idea would be for the companies to collaborate with each other, and the customer would receive just one delivery.

Given the larger set of available companies, I need to use in my constraints subsets that contain only the companies used for each customer. For example, if I have three companies, A, B, and C, how can I create a set with only companies A and B for customer I, another set with companies A and C for customer J, another set with only company B for customer K, and so on?

My idea was to create a binary parameter, 1 when the customer requests that company and 0 otherwise. But can I write this parameter in the set definition? I thought about using if and else, but I'm having trouble because the parameter depends on two variables (customer and company) and the company set only on one (company).

I'm counting on your help and am available for any questions.

Thank you!

Instead of using separate sets, you can use the idea of your binary parameters that indicate whether a company is relevant for a customer yes or no as domain conditions in your sum statements.

 

So if you have sets sCompanies and sCustomers (with indices iCompany and iCustomer respectively), you can have a binary parameter pCompanyRelevantForCustomer(iCompany, iCustomer) that has the value 1 for those combinations where iCustomer and iCompany are relevant.

 

If you then have a constraint per iCustomer where you only want to sum the relevant companies, you can do so with a statement like:

sum( iCompany | pCompanyRelevantForCustomer(iCompany, iCustomer),    parameter / variables   )

 

The | is the such-that operator and it will ensure only those iCompany elements are considered for which there is a non-zero value of the part on the right-hand side of the | operator.


Thank you for your help; it was really very useful. I was stuck trying to use "in," but AIMMS only allows the use of "in" with sets, not with parameters. So, that was a big help.

The program is giving warning notices regarding the use of "|" and suggesting replacing it with "$," and to be careful with the precedence of items. Do you know what I should be cautious about? Can I use it both in the "index domain" and in the "definition"?


With regards to the | and $, you might want to take a look at the document: https://how-to.aimms.com/Articles/593/593-dollar-or-pipe.html

 

Based on just the error, to me it is not directly clear what is the underlying problem. If you right click on any identifier in the tree in AIMMS, you can click on “Text representation” to get a textual representation of the complete identifier. You can then copy paste it here, maybe that helps to figure out why you are getting the warnings.


Reply


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

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