help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-glpk] Problem with absolute value


From: Dmitry Nadezhin
Subject: Re: [Help-glpk] Problem with absolute value
Date: Tue, 15 Jan 2013 06:09:05 +0300

Hi Alessandro,

Reginald suggeted that GLPK formulation of your problem has 8 columns
instead of 4:
S0, S1, S2, S3, Z0, Z1, Z2, Z3 ,
He expressed this in his script, but you can do the same thing in API.

  -Dima


On Tue, Jan 15, 2013 at 4:50 AM, Alessandro Saccoia
<address@hidden> wrote:
> Hi Reginald,
> thank you for pointing me to that script. I took a look, and if I will run 
> out of time I will definitely use it. The program is really cpu intensive and 
> the alignment part is an intermediate result, so I will still try to use the 
> library. dumping formatted data to disk and running another program would 
> mean to wrap everything in a script and break my original program into two 
> parts. still it's an option... thanks for your help,
> alessandro
>
> On Jan 14, 2013, at 2:34 PM, Reginald Beardsley <address@hidden> wrote:
>
>> Alessandro,
>>
>> If you look here:
>>
>> http://en.wikibooks.org/wiki/GLPK/Unix_Batch_Execution
>>
>> at script tst2a, you'll see an example of generating MathProg data files in 
>> a *nix command line environment which should be pretty much all you need.  
>> It's much less work than writing a custom program using the library calls.  
>> It also makes modifying the model much easier.
>>
>> If you need to pull the data out of something messy send me a sample.  awk 
>> is really good for tasks such as merging data from several sources or 
>> parsing complex formats.
>>
>> Have Fun!
>> Reg
>>
>> --- On Mon, 1/14/13, Alessandro Saccoia <address@hidden> wrote:
>>
>>> From: Alessandro Saccoia <address@hidden>
>>> Subject: Re: [Help-glpk] Problem with absolute value
>>> To: "Jeffrey Kantor" <address@hidden>
>>> Cc: "address@hidden" <address@hidden>
>>> Date: Monday, January 14, 2013, 6:17 AM
>>> Hi Jeff,
>>> that works wonders! Now I would just like to find a way to
>>> use the library instead of the executable, and insert all
>>> this information programmatically. In the glpk docs it seems
>>> that it's up to me to introduce all the variables and create
>>> the A matrix, but from another answer I got in pvt it looks
>>> like I can use this syntax and have the library do the
>>> necessary calculations.
>>> If I can't avoid reading the model from file, I would at
>>> least like to be able to provide the data at runtime. Thanks
>>> for your time!
>>> Alessandro
>>>
>>> On Jan 14, 2013, at 1:04 PM, Jeffrey Kantor <address@hidden>
>>> wrote:
>>>
>>>> Hi Alessandro,
>>>>
>>>> I don't exactly the geometry, but here's a MathProg
>>> model for your problem. If you want to try this out, cut and
>>> paste it into the web page at 
>>> http://www3.nd.edu/~jeff/mathprog/mathprog.html
>>>>
>>>> Jeff
>>>>
>>>>
>>>> set N := 0..3;
>>>> param q{N};
>>>> param r{N};
>>>>
>>>> param a := 0.95;
>>>> param b := 1.05;
>>>>
>>>> var z{N} >= 0;
>>>> var s{N};
>>>>
>>>> s.t. c1 {n in 0..3}: z[n] >= r[n] - s[n];
>>>> s.t. c2 {n in 0..3}: z[n] >= s[n] - r[n];
>>>> s.t. c3 {n in 0..2}: s[n+1] - s[n] >=
>>> a*(q[n+1]-q[n]);
>>>> s.t. c4 {n in 0..2}: s[n+1] - s[n] <=
>>> b*(q[n+1]-q[n]);
>>>>
>>>> minimize obj: sum{n in N} z[n];
>>>> solve;
>>>>
>>>> data;
>>>>
>>>> param q :=
>>>>      0    3
>>>>      1    5
>>>>      2    8
>>>>      3   12 ;
>>>>
>>>> param r :=
>>>>      0    2
>>>>      1    5
>>>>      2    7
>>>>      3   11 ;
>>>>
>>>> end;
>>
>>
>> _______________________________________________
>> Help-glpk mailing list
>> address@hidden
>> https://lists.gnu.org/mailman/listinfo/help-glpk
>
>
> _______________________________________________
> Help-glpk mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/help-glpk



reply via email to

[Prev in Thread] Current Thread [Next in Thread]