[Cmpl] beginner questions on problem formulation

Thomas Schleiff t.schleiff at cmpl.de
Tue Oct 10 06:08:54 EDT 2017


Hello Richard,

here some additional remarks to your questions:

3) You have defined the regions as sets, and the ports as arrays. In 
such a setup you should define the routes over the regions. For all 
routes this is simple:

     routes := [producing_regions, consuming_regions];

You can check the routes with:

     { r in routes: echo r; }

If you prefer to define the routes over the ports, then you should 
define the ports also as sets. You can make sets from your arrays by:

     export_ports_set := set{ r in producing_regions: export_ports[r] };
     import_ports_set := set{ r in consuming_regions: import_ports[r] };

Then you can define the routes with:

     routes := [export_ports_set, import_ports_set];

4) You have already defined the ports as arrays over the regions, so you 
can make the lookup within this array. You don't need the set 
producing_regions_export_ports_correspondence:

     echo export_ports["Midwest"];

will produce the output "NewOrleans".

Thomas Schleiff



Am 09.10.2017 um 11:57 schrieb Mike Steglich:
> Hello Richard,
>
> I aplolgise for the delayed answer. It is the beginning of the new 
> winter semester ...
>
> Please see my answers below:
>
> Am 06.10.2017 um 21:46 schrieb Richard Males <males at iac.net 
> <mailto:males at iac.net>>:
>
>> Thank you for the availability of CMPL and the COIN-OR project.
>>
>> I am trying to learn the language by developing a model of port to 
>> port ocean transport with a relatively small set of ports (3 export 
>> serving 3 producing regions, 7 import serving 7 consuming regions) 
>> eventually leading to a larger and more complex situation.  I come 
>> from a programming language background.  I am using Coliop4.
>>
>> Any suggestions/advice much appreciated.
>>
>> 1) I have not found any tutorial information for beginners, only the 
>> documentation.  Is there anything like that available?
>>
> Unfortunatly, not yet. There are additional CMPL sample files in the 
> SolverStudio package that could help .... -> SolverStudio.org 
> <https://urldefense.proofpoint.com/v2/url?u=http-3A__SolverStudio.org&d=DwMCaQ&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=bC-ot6cnDq3NJprIa2U54ZW0PXGvQSMdgN_s4GhXuu8&m=K-b1Y0toMDzL8qrD8mEkzPTJ9n5T6EAve5pAhb8Z8VE&s=gsdW7T_rbOwOwLPjedmbZW4IcaN_4SEM1ulJ3xk25So&e=>
>
>> 2) Is there a search function for the mailing list archive?
>>
> Unfortunately ... no
>
>> 3)   I have sets for producing and consuming regions and import and 
>> export ports (see below).
>>
>> producing_regions := set ("SouthAmerica","Midwest","PacificNorthwest");
>> export_ports[producing_regions] := ("Santos","NewOrleans","Seattle");
>> consuming_regions := set("China", "Europe", "Mexico", "Japan", 
>> "SoutheastAsia","FSU-MiddleEast","Korea");
>> import_ports[consuming_regions] := ("ChinaIP", "EuropeIP", 
>> "MexicoIP", "JapanIP", "SoutheastAsiaIP","FSU-MiddleEastIP","KoreaIP");
>>
>>
>> I am interested in developing the set of routes between all possible 
>> port pairs without having to directly enumerate it, so that I could 
>> reference route("Santos","ChinaIP") for the specifics of a particular 
>> route.  Is there an easy way of doing this within CMPL?  I did it 
>> manually, as follows:
>>
>>
>> routes := set( 
>> ["Santos","ChinaIP"],["NewOrleans","ChinaIP"],["Seattle","ChinaIP"],
>>
>> ["Santos","EuropeIP"],["NewOrleans","EuropeIP"],["Seattle","EuropeIP"],
>>
>> ["Santos","MexicoIP"],["NewOrleans","MexicoIP"],["Seattle","MexicoIP"],
>>
>> ["Santos","JapanIP"],["NewOrleans","JapanIP"],["Seattle","JapanIP"],
>>
>> ["Santos","SoutheastAsiaIP"],["NewOrleans","SoutheastAsiaIP"],["Seattle","SoutheastAsiaIP"],
>>
>> ["Santos","FSU-MiddleEastIP"],["NewOrleans","FSU-MiddleEastIP"],["Seattle","FSU-MiddleEastIP"],
>>
>> ["Santos","KoreaIP"],["NewOrleans","KoreaIP"],["Seattle","KoreaIP"]);
>>
>
> It is not possible to do that directly at the moment. I do that 
> usually in Excel using SolverStudio/Cmpl.
>
>>
>> 4) I am also looking for the best way to formulate a lookup 
>> situation.  In this case, given the region, I wish to know the port.  
>> I have created a correspondence parameter with 2-tuples, as follows
>>
>>
>> producing_regions_export_ports_correspondence:=set(["SouthAmerica","Santos"],["Midwest","NewOrleans"],["PacificNorthWest","Seattle"]);
>>
>>
>> and I would like to be able, given "Midwest", to return 
>> "NewOrleans".  I can iterate over the set to find the value, e.g.:
>>
>> # below finds correspondence by looping through all
>>
>> { [i,j] in producing_regions_export_ports_correspondence:
>>
>> {i="Midwest": echo j;}
>>
>> }
>>
>> but I am hoping there is a more direct way of doing this.
>>
>
> I would it also formulate as you did it.
>
>>
>> Thank you in advance.
>>
>>
>> Dick Males
>>
>
>
> Thanks,
>
> Mike
>
>> -- 
>> Richard M. Males
>> 3319 Eastside Avenue
>> Cincinnati, OH 45208
>> USA
>> _______________________________________________
>> Cmpl mailing list
>> Cmpl at list.coin-or.org <mailto:Cmpl at list.coin-or.org>
>> https://urldefense.proofpoint.com/v2/url?u=https-3A__list.coin-2Dor.org_mailman_listinfo_cmpl&d=DwICAg&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=Axd0FVSisUT_OdEDVlxhf3NvdBaa93RFXxvaYiKoPpk&m=K4l9MsFAnb7IG8RLm1OmTljAU3p7_w-1dh0ed4FtXIw&s=IQZAtfLxw8ga3tsrVx7ihdZehHZvKIMKkzTpd_m9noY&e= 
>>
>
>
> _______________________________________________
> Cmpl mailing list
> Cmpl at list.coin-or.org
> https://urldefense.proofpoint.com/v2/url?u=https-3A__list.coin-2Dor.org_mailman_listinfo_cmpl&d=DwICAg&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=bC-ot6cnDq3NJprIa2U54ZW0PXGvQSMdgN_s4GhXuu8&m=K-b1Y0toMDzL8qrD8mEkzPTJ9n5T6EAve5pAhb8Z8VE&s=O439QxXpwOlwDWYPu4PgpDbQ5UhP1cPl-dofJY1Wq7c&e=


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/cmpl/attachments/20171010/0e06993c/attachment.html>


More information about the Cmpl mailing list