[Cmpl] Array of sets in data file

Kamil Figiela kfigiela at agh.edu.pl
Wed Dec 11 05:23:41 EST 2013


Hello Mike,

In the end, I found good solution that allows me to specify all the data in cdat file. It may be reasonable to put it into the documentation.  

I create set of tuples that define relation between two sets in data file by using set of tuples:

> %setA set < A B C >
> %setB set < X Y >
> 
> %setC_relation set[2] < 
>   X A 
>   X B
>   Y C
> >


Then to get the desired array I do the following in CMPL parameters section:

>   {b in setB: 
>     setC[b] := set{[bi, a] in setC_relation, b = bi : a };
>   }


Full working example (updated gist): https://gist.github.com/kfigiela/7641560

Thanks,
Kamil

Wiadomość napisana przez Mike Steglich <mike.steglich at th-wildau.de> w dniu 27 lis 2013, o godz. 11:09:

> Hello Kamil,
> 
> The substitution you mentioned are not possible in Cmpl, because we didn't implement neither a substitution for symbol name (only for line names) nor a functionality like Python's eval() in Cmpl.  It could be a good idea to use pyCmpl for such things.
> 
> Thanks,
> 
> Mike
> 
> 
> Am 26.11.2013 um 11:47 schrieb Kamil Figiela:
> 
>> Hello Mike,
>> 
>> Thank you for the response. If I understand correctly, for the solution you propose I need to hardcode "setC["Y"] := setY;" lines in the model (and number of them depends on setB in this instance)? I was thinking about something like {i in setB: setC[i] := set%i;} - where %i is substituted with set member name.
>> 
>> For the time being, I will probably generate the CMPL file and use include directive.
>> 
>> Best,
>> Kamil
>> 
>> 
>> Wiadomość napisana przez Mike Steglich <mike.steglich at th-wildau.de> w dniu 25 lis 2013, o godz. 16:41:
>> 
>>> Hello Kamil,
>>> 
>>> CmplData is intended to read raw data into Cmpl models. That means it is not possible to use parameters or sets that are defined in the cmpData file for the data assignment to another set or parameter in the cmplData file.
>>> 
>>> I would like to propose to define the subsets in the cmplData file and to assign this sets to a parameter array within your Cmpl model:
>>> 
>>> ---- cmplData 
>>> %setA set < A B C >
>>> %setB set < X Y >
>>> 
>>> %setX set < A B >
>>> %setY set < C >
>>> 
>>> .... Cmpl 
>>> setC["X"] := setX;
>>> setC["Y"] := setY;
>>> 
>>> Cheers,
>>> 
>>> Mike
>>> 
>>> Am 25.11.2013 um 15:01 schrieb Kamil Figiela:
>>> 
>>>> Hello!
>>>> 
>>>> I have defined the following sets in my data file:
>>>> 
>>>> %setA set < A B C >
>>>> %setB set < X Y >
>>>> 
>>>> Now I want to define a array of sets that defines relation between sets A and B, so in the parameters section I can write:
>>>> 
>>>> setC["X"] := set("A", "B");
>>>> setC["Y"] := set("C");
>>>> 
>>>> and it works. How express the same in the data file? I have tried several options, but it didn't work. I created example program https://gist.github.com/kfigiela/7641560
>>>> 
>>>> Thanks,
>>>> Kamil Figiela_______________________________________________
>>>> Cmpl mailing list
>>>> Cmpl at list.coin-or.org
>>>> http://list.coin-or.org/mailman/listinfo/cmpl
>>> 
>> 
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4819 bytes
Desc: not available
URL: <http://list.coin-or.org/pipermail/cmpl/attachments/20131211/a9afa92b/attachment.p7s>


More information about the Cmpl mailing list