Answers from the glpk function are rounded off, which results in incorrect output.
Jaroslav Hajek
highegg at gmail.com
Mon Jan 12 01:25:32 CST 2009
On Mon, Jan 12, 2009 at 6:06 AM, Romeo Victor Dellarocco
<della1rv at gmail.com> wrote:
> --------
> Bug report for Octave 2.9.12 configured for i486-pc-linux-gnu
>
> Description:
> -----------
>
> Answers from the glpk function are rounded off,
> which results in incorrect output.
>
> I tried to solve this simple minimization problem using the glpk
> function:
> var x >= 0 ;
> var y >= 0 ;
>
> minimize p: 180*x + 160*y ;
>
> s.t. hq : 6*x + y >= 12 ;
> s.t. mq : 3*x + y >= 8 ;
> s.t. lq : 4*x + 6*y >= 24 ;
> end;
>
> I use the input file 'mines.oct', which I run through octave, which
> generates the results in 'mines.oct.out'.
>
> #$ octave -q < mines.oct > mines.oct.out
>
> The problem is that octave prints out rounded numbers, for example:
> ---
> xopt =
> 1.5000 # should be ~ 1.71
> 3.0000 # should be ~ 2.86
> ---
>
> I think that the correct answers are produced by the glpk lib, as
> 'glpksol -m mines.glpk' produces correct results in 'mines.glpk.out'.
>
> # glpksol -m mines.glpk -o mines.glpk.out
>
>
> Is there a way to keep the results from being rounded?
>
>
There is no rounding, of course. You just supplied wrong input to
glpk. In your script, ctype should be "LLL" (you have lower bounds in
b) and sense should be 1, which is minimization. The corrected script
is attached.
P.S. better do not use .oct as a suffix for scripts and m-functions,
because Octave may assume it's a compiled function.
The common suffix is .m.
P.S.2 2.9.12 is really obsolete
regards
--
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mines.m
Type: text/x-objcsrc
Size: 435 bytes
Desc: not available
Url : https://www-old.cae.wisc.edu/pipermail/bug-octave/attachments/20090112/13abbad5/attachment-0001.bin
More information about the Bug-octave
mailing list