<div dir="ltr"><div class="gmail_default" style="font-family:monospace,monospace;font-size:small">Thanks a lot !!!</div><div class="gmail_default" style="font-family:monospace,monospace;font-size:small">Now I'm having a problem using a vector of strings.</div><div class="gmail_default" style="font-family:monospace,monospace;font-size:small"><br></div><div class="gmail_default" style="font-family:monospace,monospace;font-size:small">Apparently querying a vector of strings using</div><div class="gmail_default" style="font-family:monospace,monospace;font-size:small">  <b>s[i] = VInteractions[k][1]  <br></b></div><div class="gmail_default" style="font-family:monospace,monospace;font-size:small">is not valid. I'm getting an error for the part in bold in the model. Could you tell what I'm doing wrong ?<b><br></b></div><div class="gmail_default" style="font-family:monospace,monospace;font-size:small"><br></div><div class="gmail_default" style="font-family:monospace,monospace;font-size:small">

<p style="margin:0px;text-indent:0px">parameters:</p>
<p style="margin:0px;text-indent:0px">  s[] := ("u", "c", "c", "a", "g", "c", "a", "g", "g", "a", "a", "a", "g", "c");</p>
<p style="margin:0px;text-indent:0px">     Interactions := set( "au", "cg", "gc", "gu", "ug", "ua" );</p>
<p style="margin:0px;text-indent:0px">     VInteractions[] := ( "au", "cg", "gc", "gu", "ug", "ua" );</p>
<p style="margin:0px;text-indent:0px">     # weights for different interactions</p>
<p style="margin:0px;text-indent:0px">     e[1..len(Interactions),1..len(Interactions)] :=</p>
<p style="margin:0px;text-indent:0px">       ( ( -1.1, -2.1, -2.2, -1.4, -0.9, -0.6 ),  </p>
<p style="margin:0px;text-indent:0px">           ( -2.1, -2.4, -3.3, -2.1, -2.1, -1.4 ),</p>
<p style="margin:0px;text-indent:0px">           ( -2.2, -3.3, -3.4, -2.5, -2.4, -1.5 ),</p>
<p style="margin:0px;text-indent:0px">           ( -1.4, -2.1, -2.5, -1.3, -1.3, -0.5 ),</p>
<p style="margin:0px;text-indent:0px">           ( -0.9, -2.1, -2.4, -1.3, -1.3, -1.0 ),</p>
<p style="margin:0px;text-indent:0px">             ( -0.6, -1.4, -1.5, -0.5, -1.0, -0.3 ) );</p>
<p style="margin:0px;text-indent:0px">   # penalty for pseudoknots, since there types</p>
<p style="margin:0px;text-indent:0px">   # of interactions are less common in nature</p>
<p style="margin:0px;text-indent:0px">   sigma := 0.55;</p>
<p style="margin:0px;text-indent:0px"><br></p>
<p style="margin:0px;text-indent:0px"><br></p>
<p style="margin:0px;text-indent:0px">variables:</p>
<p style="margin:0px;text-indent:0px">   # x[i,j]</p>
<p style="margin:0px;text-indent:0px">      { i in 1..count(s[])-1,j in 2..count(s[]),  i<j && s[i]+s[j] << Interactions : x[i,j] : binary; }</p>
<p style="margin:0px;text-indent:0px"><br></p>
<p style="margin:0px;text-indent:0px"><br></p>
<p style="margin:0px;text-indent:0px">   # zx[i,j]</p>
<p style="margin:0px;text-indent:0px">   { i in 1..count(s[])-3, j in 4..count(s[]), k in 1..len(Interactions), l in 1..len(Interactions),  </p>
<p style="margin:0px;text-indent:0px">     j-i >= 3 </p>
<p style="margin:0px;text-indent:0px"><b>     && s[i] = VInteractions[k][1] && s[j] = VInteractions[k][2] </b></p><b>
</b><p style="margin:0px;text-indent:0px"><b>     </b>&& s[i+1] = VInteractions[l][1] && s[j-1] = VInteractions[k][1]  : zx[i,j,k,l] : binary; }</p>
<p style="margin:0px;text-indent:0px"><br></p>
<p style="margin:0px;text-indent:0px">objectives:</p>
<p style="margin:0px;text-indent:0px">  maxInteractions: </p>
<p style="margin:0px;text-indent:0px">          sum{ i in 1..count(s[])-3, j in 4..count(s[]), k in 1..count(Interations), l in 1..count(Interations),  j-i >= 3 </p>
<p style="margin:0px;text-indent:0px">     && s[i]+s[j] << Interactions && s[i+1]+s[j-1] << Interactions : e[k,l] * zx[i,j,k,l] } -> max;</p>
<p style="margin:0px;text-indent:0px"><br></p>
<p style="margin:0px;text-indent:0px">constraints:</p>
<p style="margin:0px;text-indent:0px"><br></p>
<p style="margin:0px;text-indent:0px"><br></p> </div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 20, 2017 at 8:44 AM,  <span dir="ltr"><<a href="mailto:mike.steglich@th-wildau.de" target="_blank">mike.steglich@th-wildau.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div lang="DE"><div class="gmail-m_-8304275115060761401WordSection1"><p class="MsoNormal"><span>Hi Haroldo,<u></u><u></u></span></p><p class="MsoNormal"><span><u></u> <u></u></span></p><p class="MsoNormal"><span>Please use << to test wheter an entry is an element of a set. Your definition of the variables shout look like the following expression:<u></u><u></u></span></p><p class="MsoNormal"><span><u></u> <u></u></span></p><p class="MsoNormal">variables:<u></u><u></u></p><p class="MsoNormal">{ i in 1..count(s[]),j in 1..count(s[]), i<j, s[i]+s[j] << interactions : x[i,j] : binary; }<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal"><span><u></u> <u></u></span></p><p class="MsoNormal"><span>Thanks,<u></u><u></u></span></p><p class="MsoNormal"><span><u></u> <u></u></span></p><p class="MsoNormal"><span>Mike<u></u><u></u></span></p><p class="MsoNormal"><a name="m_-8304275115060761401__MailEndCompose"><span><u></u> <u></u></span></a></p><span></span><p class="MsoNormal"><b>Von:</b> Cmpl [mailto:<a href="mailto:cmpl-bounces@coin-or.org" target="_blank">cmpl-bounces@coin-or.<wbr>org</a>] <b>Im Auftrag von </b>Haroldo Santos<br><b>Gesendet:</b> Sonntag, 19. November 2017 20:22<br><b>An:</b> <a href="mailto:cmpl@list.coin-or.org" target="_blank">cmpl@list.coin-or.org</a><br><b>Betreff:</b> [Cmpl] Conditional creation of variables<u></u><u></u></p><div><div class="gmail-h5"><p class="MsoNormal"><u></u> <u></u></p><div><div><p class="MsoNormal"><span style="font-size:12pt;font-family:"Courier New"">Hi,<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:12pt;font-family:"Courier New""><u></u> <u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:12pt;font-family:"Courier New"">I'm working with a computational biology problem where the input is a string.<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:12pt;font-family:"Courier New""><u></u> <u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:12pt;font-family:"Courier New"">I would like to create variables for pairs of positions (i,j : i<j) in this string where a matching is possible.<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size:12pt;font-family:"Courier New""><u></u> <u></u></span></p></div><div><p style="margin:0cm 0cm 0.0001pt"><span style="font-size:12pt;font-family:"Courier New""><u></u> <u></u></span></p><p style="margin:0cm 0cm 0.0001pt"><span style="font-size:12pt;font-family:"Courier New";color:blue">parameters:</span><span style="font-size:12pt;font-family:"Courier New""><u></u><u></u></span></p><p style="margin:0cm 0cm 0.0001pt"><span style="font-size:12pt;font-family:"Courier New";color:blue">    s[] := ("u", "c", "c", "a", "g", "c", "a", "g", "g", "a", "a", "a", "g", "c");</span><span style="font-size:12pt;font-family:"Courier New""><u></u><u></u></span></p><p style="margin:0cm 0cm 0.0001pt"><span style="font-size:12pt;font-family:"Courier New";color:blue">    interactions := set( "au", "cg", "gc", "gu", "ug", "ua" );</span><span style="font-size:12pt;font-family:"Courier New""><u></u><u></u></span></p><p style="margin:0cm 0cm 0.0001pt"><span style="font-size:12pt;font-family:"Courier New""><u></u> <u></u></span></p><p style="margin:0cm 0cm 0.0001pt"><span style="font-size:12pt;font-family:"Courier New";color:blue">variables:</span><span style="font-size:12pt;font-family:"Courier New""><u></u><u></u></span></p><p style="margin:0cm 0cm 0.0001pt"><span style="font-size:12pt;font-family:"Courier New";color:blue">    { i in 1..count(s[]),j in 1..count(s[]), i<j && s[i]+s[j] in interactions : x[i,j] : binary; }</span><span style="font-size:12pt;font-family:"Courier New""><u></u><u></u></span></p><p style="margin:0cm 0cm 0.0001pt"><span style="font-size:12pt;font-family:"Courier New""><u></u> <u></u></span></p><p style="margin:0cm 0cm 0.0001pt"><span style="font-size:12pt;font-family:"Courier New""><u></u> <u></u></span></p><p style="margin:0cm 0cm 0.0001pt"><span style="font-size:12pt;font-family:"Courier New"">The error appeared after I inserted  <span style="color:blue">&& s[i]+s[j] in interactions  .</span><span style="color:black"> The intent of this part was to limit the creation of these variables only for valid matches (specified in interactions).</span><u></u><u></u></span></p><p style="margin:0cm 0cm 0.0001pt"><span style="font-size:12pt;font-family:"Courier New""><u></u> <u></u></span></p><p style="margin:0cm 0cm 0.0001pt"><span style="font-size:12pt;font-family:"Courier New";color:black">Could someone tell me what is wrong ?</span><span style="font-size:12pt;font-family:"Courier New""><u></u><u></u></span></p><p style="margin:0cm 0cm 0.0001pt"><span style="font-size:12pt;font-family:"Courier New""><u></u> <u></u></span></p><p style="margin:0cm 0cm 0.0001pt"><span style="font-size:12pt;font-family:"Courier New";color:black">Thanks  </span><span style="font-size:12pt;font-family:"Courier New""><u></u><u></u></span></p><p style="margin:0cm 0cm 0.0001pt"><span style="font-size:12pt;font-family:"Courier New""><u></u> <u></u></span></p></div><p class="MsoNormal"><br>-- <u></u><u></u></p><div><div><div><p class="MsoNormal"><span style="font-family:"Courier New"">==============================<wbr>==============================<wbr>=<br>Haroldo Gambini Santos<br>Computing Department<br>Universidade Federal de Ouro Preto - UFOP<br>email: haroldo [at ] <a href="http://iceb.ufop.br" target="_blank">iceb.ufop.br</a><br>home/research page: <a href="http://www.decom.ufop.br/haroldo/" target="_blank">www.decom.ufop.br/haroldo</a><br><br><br>It has long been an axiom of mine that the little things are infinitely<br>the most important.<br>-- Sir Arthur Conan Doyle, "A Case of Identity"</span><u></u><u></u></p></div></div></div></div></div></div></div></div></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature"><div dir="ltr"><div><span style="font-family:monospace,monospace">=============================================================<br>Haroldo Gambini Santos<br>Computing Department<br>Universidade Federal de Ouro Preto - UFOP<br>email: haroldo [at ] <a href="http://iceb.ufop.br" target="_blank">iceb.ufop.br</a><br>home/research page: <a href="http://www.decom.ufop.br/haroldo/" target="_blank">www.decom.ufop.br/haroldo</a><br><br><br>It has long been an axiom of mine that the little things are infinitely<br>the most important.<br>           -- Sir Arthur Conan Doyle, "A Case of Identity"<br></span></div></div></div>
</div></div>