[Cmpl] Conditional creation of variables
Haroldo Santos
haroldo.santos at gmail.com
Tue Nov 21 18:48:19 EST 2017
Thanks a lot !!!
Now I'm having a problem using a vector of strings.
Apparently querying a vector of strings using
*s[i] = VInteractions[k][1] *
is not valid. I'm getting an error for the part in bold in the model. Could
you tell what I'm doing wrong ?
parameters:
s[] := ("u", "c", "c", "a", "g", "c", "a", "g", "g", "a", "a", "a", "g",
"c");
Interactions := set( "au", "cg", "gc", "gu", "ug", "ua" );
VInteractions[] := ( "au", "cg", "gc", "gu", "ug", "ua" );
# weights for different interactions
e[1..len(Interactions),1..len(Interactions)] :=
( ( -1.1, -2.1, -2.2, -1.4, -0.9, -0.6 ),
( -2.1, -2.4, -3.3, -2.1, -2.1, -1.4 ),
( -2.2, -3.3, -3.4, -2.5, -2.4, -1.5 ),
( -1.4, -2.1, -2.5, -1.3, -1.3, -0.5 ),
( -0.9, -2.1, -2.4, -1.3, -1.3, -1.0 ),
( -0.6, -1.4, -1.5, -0.5, -1.0, -0.3 ) );
# penalty for pseudoknots, since there types
# of interactions are less common in nature
sigma := 0.55;
variables:
# x[i,j]
{ i in 1..count(s[])-1,j in 2..count(s[]), i<j && s[i]+s[j] <<
Interactions : x[i,j] : binary; }
# zx[i,j]
{ i in 1..count(s[])-3, j in 4..count(s[]), k in 1..len(Interactions), l in
1..len(Interactions),
j-i >= 3
* && s[i] = VInteractions[k][1] && s[j] = VInteractions[k][2] *
&& s[i+1] = VInteractions[l][1] && s[j-1] = VInteractions[k][1] :
zx[i,j,k,l] : binary; }
objectives:
maxInteractions:
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
&& s[i]+s[j] << Interactions && s[i+1]+s[j-1] << Interactions : e[k,l] *
zx[i,j,k,l] } -> max;
constraints:
On Mon, Nov 20, 2017 at 8:44 AM, <mike.steglich at th-wildau.de> wrote:
> Hi Haroldo,
>
>
>
> Please use << to test wheter an entry is an element of a set. Your
> definition of the variables shout look like the following expression:
>
>
>
> variables:
>
> { i in 1..count(s[]),j in 1..count(s[]), i<j, s[i]+s[j] << interactions :
> x[i,j] : binary; }
>
>
>
>
>
> Thanks,
>
>
>
> Mike
>
>
>
> *Von:* Cmpl [mailto:cmpl-bounces at coin-or.org] *Im Auftrag von *Haroldo
> Santos
> *Gesendet:* Sonntag, 19. November 2017 20:22
> *An:* cmpl at list.coin-or.org
> *Betreff:* [Cmpl] Conditional creation of variables
>
>
>
> Hi,
>
>
>
> I'm working with a computational biology problem where the input is a
> string.
>
>
>
> I would like to create variables for pairs of positions (i,j : i<j) in
> this string where a matching is possible.
>
>
>
>
>
> parameters:
>
> s[] := ("u", "c", "c", "a", "g", "c", "a", "g", "g", "a", "a", "a",
> "g", "c");
>
> interactions := set( "au", "cg", "gc", "gu", "ug", "ua" );
>
>
>
> variables:
>
> { i in 1..count(s[]),j in 1..count(s[]), i<j && s[i]+s[j] in
> interactions : x[i,j] : binary; }
>
>
>
>
>
> The error appeared after I inserted && s[i]+s[j] in interactions . The
> intent of this part was to limit the creation of these variables only for
> valid matches (specified in interactions).
>
>
>
> Could someone tell me what is wrong ?
>
>
>
> Thanks
>
>
>
>
> --
>
> =============================================================
> Haroldo Gambini Santos
> Computing Department
> Universidade Federal de Ouro Preto - UFOP
> email: haroldo [at ] iceb.ufop.br
> home/research page: www.decom.ufop.br/haroldo
>
>
> It has long been an axiom of mine that the little things are infinitely
> the most important.
> -- Sir Arthur Conan Doyle, "A Case of Identity"
>
--
=============================================================
Haroldo Gambini Santos
Computing Department
Universidade Federal de Ouro Preto - UFOP
email: haroldo [at ] iceb.ufop.br
home/research page: www.decom.ufop.br/haroldo
It has long been an axiom of mine that the little things are infinitely
the most important.
-- Sir Arthur Conan Doyle, "A Case of Identity"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/cmpl/attachments/20171121/f1a12a26/attachment.html>
More information about the Cmpl
mailing list