<html><head><base href="x-msg://42/"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">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></body></html>