[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-glpk] Problem with absolute value
From: |
Reginald Beardsley |
Subject: |
Re: [Help-glpk] Problem with absolute value |
Date: |
Mon, 14 Jan 2013 05:34:04 -0800 (PST) |
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] 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 <=
- 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, 2013/01/16
- Re: [Help-glpk] Problem with absolute value, Jeffrey Kantor, 2013/01/16
- Re: [Help-glpk] Problem with absolute value, Alessandro Saccoia, 2013/01/17