Solved

Question regarding the union of sets

  • 23 September 2021
  • 6 replies
  • 277 views

Badge

Hello everyone,

I am trying to implement a supply and demand model in AIMMS. This is the first time using it for me and I'm having some issues. 

The case is as follows: There are Printer companies that supply books to Retailers. These Printers can send the books directly to retailers, or through crossdocks to be consolidated. 

I have modelled the set of Printers with index P, the set of Crossdocks with index C and the set of retailers with index R. The case asks for a set of locations as the union of these three sets L = P ∪  C ∪ R. I am not sure how to model this union of sets and can't seem to find any info on this. Does anyone know how to do this?

Not sure if it matters, but the amount of Printers, Crossdocks and Retailers should be variable and dependent on an Excel input file.

 

Thanks!

icon

Best answer by Gertjan 23 September 2021, 23:17

View original

6 replies

Userlevel 3
Badge +3

I just create a new topic on the suggested set construction. Perhaps interesting to read.

Filling a set via the union of its subsets | AIMMS Community

Userlevel 6
Badge +6

@WRuijsscher

to have others find your new question, it best to post this as a new item (possibly linking to your previous post if that is helpful) as this current item is considered ‘answered’ and therefor is easily skipped.

 

A hint to solve this one: use the index ‘i’ in Locations and limit it by the subsets you mention in the sum. See for example where index ‘k’ is limited:

 

Badge

I have one more follow-up question. Most of the required constraints are limited to just two of the subsets, such as Crossdocks and Retailers, see the following constraint:

How does this need to be modelled in Aimms? Especially the red underligned part I'm not too sure about. Thank you.

Userlevel 6
Badge +6

I think this is solved if you do a full compile (F5) as they depend on each other. Else, restart the project to make sure all is re-evaluated.

As a full example (just to be sure):

	Set Locations {
Index: l;
Definition: Printers + CrossDocks + Retailers;
}
Set Printers {
SubsetOf: Locations;
Index: p;
Definition: ElementRange(1,10, prefix:"p-", fill: 1);
}
Set CrossDocks {
SubsetOf: Locations;
Index: c;
Definition: ElementRange(1,3, prefix:"c-", fill: 1);
}
Set Retailers {
SubsetOf: Locations;
Index: r;
Definition: ElementRange(1,25, prefix:"r-", fill: 1);
}

results in:

Locations := data 
{ p-01, p-02, p-03, p-04, p-05, p-06, p-07, p-08, p-09, p-10, c-1 , c-2 , c-3 , r-01, r-02, r-03, r-04, r-05, r-06, r-07, r-08, r-09, r-10, r-11, r-12, r-13, r-14, r-15, r-16, r-17, r-18, r-19, r-20, r-21, r-22, r-23, r-24, r-25 } ;

Of course you can read the data from other sources instead of generating it. Also, you could generate it dynamically by replacing the 10, 3, 25 respectively with a Parameter of range {1 .. n }, e.g. NoCrossdocks. If you assign 25 to NoCrossdocks, the set will be generated as above again. 

Badge

Hi @Gertjan 

Thanks for your answer! I defined it all like you described, but now I get the error that Aimms detected a cyclic definition: Locations [definition] (1,0). There isn't any data in the model yet, so is this supposed to happen?

Thanks again.

Userlevel 6
Badge +6

Hi @WRuijsscher 

You can define a set of ‘Locations’ (with eg index l) and then add to all other sets ‘Locations’ in the ‘subset of’ property. The set ‘Locations’ can then be defined using the definition property: Printers + Crossdocks + Retailers.

Good to know: If you read in the subsets, the set Locations will be automatically updated as it has a definition 😀!


A more extensive explanation can be found here: https://documentation.aimms.com/language-reference/non-procedural-language-components/set-declaration/set-declaration-and-attributes.html.

 

 

Reply


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

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