<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Hi Michael,</div><div><br></div><div>The first example I sent should work because it was running on my system.</div><div><br></div><div>One of the reasons to suggest a cmplData file is that a csv file can only consists of a dense vector matrix. A cmplFile can contain dense or sparse n-dimensional arrays with n&gt;2. CmplData is the official data file format for Cmpl.</div><div><br></div><div>Cheers,</div><div><br></div><div>Mike</div><div><br>Am 12.09.2013 um 21:49 schrieb Michael Bond &lt;<a href="mailto:mbond@videologygroup.com">mbond@videologygroup.com</a>&gt;:<br><br></div><blockquote type="cite"><div>

<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">



<div name="divtagdefaultwrapper" id="divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:#000000; margin:0">
Oh right, my example should have been set(...) but the question is still the same, I can't get r[plants,markets] := readcsv("r.csv") to work. I've tried a variety different orders to the data and none seem to parse correctly.
<div><br>
</div>
<div>I have managed to successfully use .cdat and even include a separate cmpl file. I'll probably end up using cmpl due to the fact that the grouping is more explicit but would still like to get a sample .csv working.</div>
<div><br>
</div>
<div>As a followup question, what would a three-dimension .csv look like, for instance adding time to r?</div>
<div><br>
</div>
<div>
<div style="color:rgb(40,40,40)">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Mike Steglich &lt;<a href="mailto:mike.steglich@berlin.de">mike.steglich@berlin.de</a>&gt;<br>
<b>Sent:</b> Thursday, September 12, 2013 3:22 PM<br>
<b>To:</b> Michael Bond<br>
<b>Cc:</b> <a href="mailto:cmpl@list.coin-or.org">cmpl@list.coin-or.org</a><br>
<b>Subject:</b> Re: [Cmpl] Question about readcsv and multi-dimension arrays</font>
<div>&nbsp;</div>
</div>
<div>Hi Michael,
<div><br>
</div>
<div>Welcome to the CMPL user group!</div>
<div><br>
</div>
<div>If you want to specify sets within a parameters section you have to use the keyword set as follows:</div>
<div><br>
</div>
<div>&nbsp; &nbsp; parameters:<br>
&nbsp; &nbsp; &nbsp; &nbsp; plants := set("seattle", "san_diego");<br>
&nbsp; &nbsp; &nbsp; &nbsp; markets := set("new_york", "chicago", "topeka");</div>
<div><br>
</div>
<div>After these expressions you can read the data with the csv file&nbsp;<br>
&nbsp; &nbsp; &nbsp; &nbsp; r[plants, markets] := readcsv("r.csv");</div>
<div><br>
</div>
<div>and do what you want with the date; e.g. print the values:</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>{i in plants, j in markets: echo r[i,j]; }</div>
<div><br>
</div>
<div><br>
</div>
<div>I would like to propose that you use a cmplData file instead a csv file because this file format is more flexible.</div>
<div><br>
</div>
<div>The formulation of the cmplData file r.cdat for your example looks like follows:</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>%plants set &lt; seattle san_diego &gt;<br>
<span class="Apple-tab-span" style="white-space:pre"></span>%markets &nbsp;set &lt;new_york chicago topeka&gt;<br>
<br>
<span class="Apple-tab-span" style="white-space:pre"></span>%r[plants, markets] &lt;&nbsp;<span class="Apple-tab-span" style="white-space:pre">
</span>2.5 1.7 1.8&nbsp;<br>
<span class="Apple-tab-span" style="white-space:pre"></span>2.5 1.8 1.4 &gt;&nbsp;<br>
<br>
</div>
<div>You can read the sets and the parameter array with the CMPL header entry %data:</div>
<div><br>
</div>
<div>
<div><font class="Apple-style-span" color="#000000"><span class="Apple-tab-span" style="white-space:pre"></span>%data r.cdat&nbsp;</font></div>
<div><font class="Apple-style-span" color="#000000">&nbsp; &nbsp;<span class="Apple-tab-span" style="white-space:pre">
</span>parameters:</font></div>
<div></div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>{i in plants, j in markets: echo r[i,j]; }</div>
</div>
<div><br>
</div>
<div>Cheers,</div>
<div><br>
</div>
<div>Mike</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
<div>
<div>Am 12.09.2013 um 20:22 schrieb Michael Bond:</div>
<br class="Apple-interchange-newline">
<blockquote type="cite">
<div dir="ltr" tabindex="0">
<div name="divtagdefaultwrapper" id="divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px">
I'm just getting started with CMPL and have what seems like a rather basic question. Given the following CMPL model how what should the csv for r be formatted:
<div><br>
</div>
<div>&nbsp; &nbsp; parameters:</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; plants := "seattle", "san_diego"</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; markets := "new_york", "chicago", "topeka"</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; r[plants, markets] := readcsv("r.csv");</div>
<div><br>
</div>
<div>Using the following in r.csv:</div>
<div><br>
</div>
<div>
<div>2.5,1.7,1.8</div>
<div>2.5,1.8,1.4</div>
</div>
<div><br>
</div>
<div>I get the following errors:</div>
<div><br>
</div>
<div>
<div>
<div>error (interpreter): file transport.cmpl line 9: Count of elements for the 1. index of 'r' is wrong</div>
<div>error (interpreter): file transport.cmpl line 9: Count of elements for the 2. index of 'r' is wrong</div>
</div>
</div>
<div><br>
</div>
<div>Using the following in r.csv:</div>
<div><br>
</div>
<div>
<div>new_york,chicago,topeka</div>
<div>seattle,2.5,1.7,1.8</div>
<div>san_diego,2.5,1.8,1.4</div>
</div>
<div><br>
</div>
<div>
<div>I get the following errors:</div>
<div><br>
</div>
<div>
<div>error (interpreter): file transport.cmpl line 9: Count of elements for the 1. index of 'r' is wrong</div>
<div>error (interpreter): file transport.cmpl line 9: Count of elements for the 2. index of 'r' is wrong</div>
<div>error (interpreter): file transport.cmpl line 9: Count of elements for the 2. index of 'r' is wrong</div>
<div>error (interpreter): file transport.cmpl line 9: Count of elements for the 2. index of 'r' is wrong</div>
</div>
<div><br>
</div>
<div>I've tried a number of other variations with no success. I've seen the readcsv examples that use an unbounded array (r[,]) but for would prefer to use bounded arrays. Any help would be welcome.</div>
<div>
<div></div>
</div>
</div>
</div>
<b>This email is intended only for the use of the individual(s) to whom it is addressed. If you have received this communication in error, please immediately notify the sender and delete the original email.</b>_______________________________________________<br>
Cmpl mailing list<br>
<a href="mailto:Cmpl@list.coin-or.org">Cmpl@list.coin-or.org</a><br>
<a href="http://list.coin-or.org/mailman/listinfo/cmpl">http://list.coin-or.org/mailman/listinfo/cmpl</a></div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
</div>
<b>This email is intended only for the use of the individual(s) to whom it is addressed. If you have received this communication in error, please immediately notify the sender and delete the original email.</b>


</div></blockquote></body></html>