[Scip] Define parameters in ZIMPL

Thorsten Koch koch at zib.de
Sun May 16 10:31:43 MEST 2010


Am 16.05.2010 10:20, schrieb Julio Rojas:
> Dear Thornsten, I'm sorry for my lack of clarity. What I would like is to
> fill position <i,j> of the parameter matrix "s" with position <k> of a
> vector or set of values.

But you need some connect betwwen i,j and k or should k just be incremented?



 I would really like to learn how to solve it
> directly in ZIMPL, as the regular way of doing it would require using two
> (very costly in time) loops that build the string "par s[<i,j> in e2] :=
> <1,2> 1, <1,3> 2, ... , <n-1,n> (n^2 - n)/2;

That would be:

par s[<i,j> in e2] := <i,j>( ((i -1)* card(p) + (j-1))^2 - ((i -1)*
card(p) + (j-1))) / 2;

Best regards,
Thorsten

> 
> If there's no possible way, don't worry, I won't keep trying to pull a
> Phillips screw with a flat screwdriver. ;) Besides, I have already solve it
> from my source code without using the loops, although
> curiosity still lingers on. I hope
> 
> I have been sufficiently clear. Best regards.
> -------------------------------------------------
> Julio Rojas
> jcredberry at gmail.com
> 
> 
> On Sun, May 16, 2010 at 12:21 AM, Thorsten Koch <koch at zib.de> wrote:
> 
>> Dear Julio,
>>
>> it is not clera to what you want to achieve.
>>
>> Am 15.05.2010 16:38, schrieb Julio Rojas:
>>> Dear Thorsten, I have followed your advice and changed my code to:
>>>
>>> param s[<i,j> in e2] := ord(p,j in {1..card(p)},1) default 0;
>>>
>>
>> s[3,4] has to resolve to a single number.
>>
>> What do you want from the  j in { 1 .. 3 } ?
>> j is already fixed from the s[<i,j> in e2] so it is some number.
>> But then    2 in { 1 .. 3} does not make much sense.
>>
>> Best regards,
>> Thorsten
>>
>>
>>
>>> Now, the error changed to:
>>>
>>> Reading problem.zpl
>>> *** Error 800: File problem.zpl Line 7 : syntax error, unexpected IN,
>>> expecting
>>> ',' or '+' or '-'
>>> *** aram s[<i,j> in e2] := ord(p,k in {1..card(p)},1) default 0;
>>> ***                                 ^^^
>>>
>>> Any other idea? Am I forcing things and should stick to define the
>>> parameters by hand from my program (two loops)?
>>>
>>> Best regards.
>>> -------------------------------------------------
>>> Julio Rojas
>>> jcredberry at gmail.com
>>>
>>>
>>> On Sat, May 15, 2010 at 3:35 PM, Thorsten Koch <koch at zib.de> wrote:
>>>
>>>> Dear Julio,
>>>>
>>>> you can not access a member of a set (p) by use of [].
>>>> if you do p[] you try to access an array of sets (which is not defined
>>>> in this case)
>>>> You can access a member of a set using the ord() function.
>>>>
>>>> Furthermore, a parameter is always only a single value.
>>>>
>>>> Here
>>>>> param s[<i,j> in e2] := p[i in {1..card(p)}] default 0;
>>>>                             ^
>>>>                       This i
>>>> is equal to the i from <i,j>.
>>>> The expression on the right hand side is not depending on j.
>>>> In any case it should read p[<i> in ...  but this won't work either.
>>>>
>>>> But I believe ord() will do what you need.
>>>>
>>>> Best regards,
>>>> Thorsten
>>>>
>>>>
>>>> param s[<i,j> in e2] := ord(p([i in {1..card(p)}] default 0;
>>>>
>>>> Am 14.05.2010 20:18, schrieb Julio Rojas:
>>>>> Dear Armin and Ambros, not really. I'll like to put the k-th element of
>>>> the
>>>>> set p in the <i,j>-th position of the parameter matrix s. I have
>> already
>>>>> defined e2 (but didn't put it in my previous email) and I wouldn't like
>>>> to
>>>>> create the matrix of parameters one by one as it is stated in the
>> manual.
>>>>> The matrix s is a triangular matrix with zeros in the diagonal (in
>>>> reality
>>>>> is a distance matrix). I would like to fill each element of the matrix
>>>> from
>>>>> a set. This way I will not have to make a double loop in my code to
>>>> define
>>>>> each element <i,j> with i<j. This is the code I already have:
>>>>>
>>>>> set nodes := {"1","2","3"};
>>>>> set e2 := {<i,j> in nodes*nodes with i<j};
>>>>> set p := {.1,.2,.3};
>>>>> var y[<i,j> in e2] binary;
>>>>> var x[<i> in nodes] binary;
>>>>> param s[<i,j> in e2] := p[i in {1..card(p)}] default 0;
>>>>> maximize sim: sum<i,j> in e2: s[i,j]*y[i,j];
>>>>>
>>>>> Best regards.
>>>>> -------------------------------------------------
>>>>> Julio Rojas
>>>>> jcredberry at gmail.com
>>>>>
>>>>>
>>>>> 2010/5/14 Armin Fügenschuh <fuegenschuh at zib.de>
>>>>>
>>>>>> Dear Julio,
>>>>>>
>>>>>> is this the thing you're trying to do?
>>>>>>
>>>>>> set p := {.1,.2,.3};
>>>>>> set e2 := p*p;
>>>>>> param s[<i,j> in e2] := j;
>>>>>> var y[e2] real;
>>>>>> maximize sim: sum<i,j> in e2: s[i,j]*y[i,j];
>>>>>>
>>>>>>
>>>>>> Regards,
>>>>>> Armin
>>>>>>
>>>>>>
>>>>>> 2010/5/14 Julio Rojas <jcredberry at gmail.com>
>>>>>>
>>>>>>> Dear all, I would like to define the matrix of parameters from a set.
>> I
>>>>>>> have tried with the following:
>>>>>>>
>>>>>>> set p := {.1,.2,.3};
>>>>>>> param s[<i,j> in e2] := p[i in {1..card(p)}] default 0;
>>>>>>> maximize sim: sum<i,j> in e2: s[i,j]*y[i,j];
>>>>>>>
>>>>>>> The following message appears:
>>>>>>>
>>>>>>> *** Error 800: File problem.zpl Line 7 : syntax error, unexpected
>>>> SETSYM
>>>>>>> *** param s[<i,j> in e2] := p[<i> in {1..card(p)}] default 0;
>>>>>>> ***                         ^^^
>>>>>>>
>>>>>>> Is there a way to do this? Thanks in advance.
>>>>>>> -------------------------------------------------
>>>>>>> Julio Rojas
>>>>>>> jcredberry at gmail.com
>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> Scip mailing list
>>>>>>> Scip at zib.de
>>>>>>> http://listserv.zib.de/mailman/listinfo/scip
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>>
>>>>>> Dr. Armin Fügenschuh
>>>>>>
>>>>>> Konrad-Zuse-Zentrum für
>>>>>> Informationstechnik Berlin (ZIB)
>>>>>>
>>>>>> Division Scientific Computing
>>>>>> Department Optimization
>>>>>>
>>>>>> Takustrasse 7
>>>>>> 14195 Berlin
>>>>>>
>>>>>> Tel. : +49 (0)30 84185-205
>>>>>> Fax: +49 (0)30 84185-269
>>>>>> email: fuegenschuh at zib.de
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Scip mailing list
>>>>> Scip at zib.de
>>>>> http://listserv.zib.de/mailman/listinfo/scip
>>>>
>>>> --
>>>> The important thing is not to stop questioning.
>>>> Curiosity has its own reason for existing.          -- Albert Einstein
>>>> ______________________________________________________________________
>>>> Dr. Thorsten Koch / Konrad-Zuse-Zentrum für Informationstechnik Berlin
>>>> www.zib.de/koch  /          Takustraße 7, 14195 Berlin-Dahlem, Germany
>>>> koch at zib.de     /                     Phone +49-30-84185-213, Fax -269
>>>> _______________/  DFG Research Center "Matheon"  http://www.matheon.de
>>>>
>>>> Kooperativer Bibliotheksverbund Berlin Brandenburg  http://www.kobv.de
>>>> ______________________________________________________________________
>>>>
>>>
>>
>> --
>> The important thing is not to stop questioning.
>> Curiosity has its own reason for existing.          -- Albert Einstein
>> ______________________________________________________________________
>> Dr. Thorsten Koch / Konrad-Zuse-Zentrum für Informationstechnik Berlin
>> www.zib.de/koch  /          Takustraße 7, 14195 Berlin-Dahlem, Germany
>> koch at zib.de     /                     Phone +49-30-84185-213, Fax -269
>> _______________/  DFG Research Center "Matheon"  http://www.matheon.de
>>
>> Kooperativer Bibliotheksverbund Berlin Brandenburg  http://www.kobv.de
>> ______________________________________________________________________
>>
> 

-- 
The important thing is not to stop questioning.
Curiosity has its own reason for existing.          -- Albert Einstein
______________________________________________________________________
Dr. Thorsten Koch / Konrad-Zuse-Zentrum für Informationstechnik Berlin
www.zib.de/koch  /          Takustraße 7, 14195 Berlin-Dahlem, Germany
koch at zib.de     /                     Phone +49-30-84185-213, Fax -269
_______________/  DFG Research Center "Matheon"  http://www.matheon.de

Kooperativer Bibliotheksverbund Berlin Brandenburg  http://www.kobv.de
______________________________________________________________________


More information about the Scip mailing list