[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-glpk] Problem with absolute value
From: |
Alessandro Saccoia |
Subject: |
Re: [Help-glpk] Problem with absolute value |
Date: |
Wed, 16 Jan 2013 23:43:21 +0100 |
Hey Jeff, Reginald et al.
I was really rushed to finish this implementation by today, so I have
eventually generated the data file on the fly, called glpsol and parsed its
results. Not an optimal solution I know, but for this time it works. I
sincerely thank you for the time you spent helping me, and I would be
interested as soon as I have time to implement an easy C++ interface to the
library. It's not much work and since I am sure that I will use it again in the
future, there would already be a first user.
Keep in touch, thanks again
Alessandro
On Jan 15, 2013, at 5:32 AM, Reginald Beardsley <address@hidden> wrote:
> All I was pointing out is how to generate the syntactic sugar (e.g. "param P
> :=" ) for the data section in the context of an example I made up. It had
> nothing to do with Alessandro's problem.
>
> BTW I just noticed there's another section on scripting with MathProg which
> does things rather differently. It might be good to move the two together
> and structure by environment and task e.g. parameter scanning, batch
> execution, etc.
>
> FWIW I tend to be very incremental in developing problem logic and often have
> a dozen or more scripts and programs called from a driver script. This makes
> it easier to inspect the steps along the way.
>
> It's very awkward to examine a large array in a debugger. Much better to
> dump it as a binary or ASCII file and look at that. This is particularly
> important if you're pulling data from a large database which has data
> corruption issues to be dealt with. In the data I deal with I expect 1-2% bad
> data, so it saves time to dump the data in a viewable format at key steps in
> the process for review before proceeding to the next step. It costs computer
> resources, but with big memories and multiple cores it's not really a
> problem. I just start the jobs and go do something else for a while. The
> goal is to save my time. I can scan several thousand plots very quickly
> looking for problem data.
>
> I should note that I developed this style on projects that take 100's of GB
> of data from multiple sources and require 9-12 months to complete. For them
> I might write 40-50 scripts and small programs in addition to using any
> number of existing programs. It's hard enough done in many small steps.
> Doing it in a single large program would probably be unsuccessful with a
> brickwall deadline. I'd certainly be unwilling to try anything that large
> with a hard deadline. I tend to use it a lot because I never know where
> projects will head, but it's not needed for small well defined tasks. It's
> also not well suited to repetitive work as there are too many moving parts to
> keep track of. So a repeat of the same work will lead to an emphasis on
> consolidating things into fewer steps.
>
> Have Fun!
> Reg
>
> --- On Mon, 1/14/13, Dmitry Nadezhin <address@hidden> wrote:
>
>> From: Dmitry Nadezhin <address@hidden>
>> Subject: Re: [Help-glpk] Problem with absolute value
>> To: "Alessandro Saccoia" <address@hidden>
>> Cc: "Reginald Beardsley" <address@hidden>, "glpk" <address@hidden>
>> Date: Monday, January 14, 2013, 9:09 PM
>> 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
>>
>
> _______________________________________________
> Help-glpk mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/help-glpk
- [Help-glpk] Problem with absolute value, Alessandro Saccoia, 2013/01/13
- Re: [Help-glpk] Problem with absolute value, Jeffrey Kantor, 2013/01/14
- Re: [Help-glpk] Problem with absolute value, Alessandro Saccoia, 2013/01/14
- Re: [Help-glpk] Problem with absolute value, Reginald Beardsley, 2013/01/14
- Re: [Help-glpk] Problem with absolute value, Alessandro Saccoia, 2013/01/14
- Re: [Help-glpk] Problem with absolute value, Dmitry Nadezhin, 2013/01/14
- Re: [Help-glpk] Problem with absolute value, Reginald Beardsley, 2013/01/14
- Re: [Help-glpk] Problem with absolute value,
Alessandro Saccoia <=
- Re: [Help-glpk] Problem with absolute value, Jeffrey Kantor, 2013/01/16
- Re: [Help-glpk] Problem with absolute value, Alessandro Saccoia, 2013/01/17