[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-glpk] [Fwd: Find nearest point]
From: |
glpk xypron |
Subject: |
Re: [Help-glpk] [Fwd: Find nearest point] |
Date: |
Wed, 15 Jun 2011 21:30:19 +0200 |
Hello Paul,
GLPK only calculates with limited precision.
Unfortunately you have chosen big_number unreasonably high. If
you change it to 10, you get the expected result.
In a big M approach you should always use the smallest possible
number for M.
The problem is recurring cf.
http://lists.gnu.org/archive/html/help-glpk/2011-04/msg00021.html
I added a paragraph in the Wikibook
http://en.wikibooks.org/wiki/GLPK/Modeling_tips#Big_M
Best regards
Xypron
> -------- Forwarded Message --------
> Subject: Find nearest point
> Date: Wed, 15 Jun 2011 10:10:25 +0200 (CEST)
>
> Hi.
>
> I'm currently working on a project that aims to compute the consign we
> should give to an uav in order to reach a point.
>
> The first step has been to model the problem without obstacles. It seems
> to work (we find the straight line :) ).
>
> Now we need to add obstacles. And in my new model, glpk seems to ignore
> some constraints.
>
> I tried to make a minimalist example to reproduce the "problem".
>
> When i run this example, b[0] and b[1] both equals 0 and i wonder how c6
> is satisfied ?
>
> I suppose that i have made a mistake. Could you explain my why ?
>
> Thank you.
>
> Paul.
>
>
>
>
> # trivial.dat
> data;
> param big_number := 100000;
> param xref := 5;
> param xobs := 5;
> param cobs := 1;
> end;
>
> #trivial .mod
> param big_number;
> # reference coordinate
> param xref;
> # obstacle coordinate
> param xobs;
> # obstacle side
> param cobs;
>
> var x;
> var xerr;
> var b{i in 1..2}, binary;
>
> minimize f : xerr;
>
> # xerr = abs(x - xref)
> s.t. c1 : x - xref <= xerr;
> s.t. c2 : -x + xref <= xerr;
>
> # b[1] = 0 if x is to the left of xobs
> s.t. c3 : x >= xobs - cobs - big_number * (1 - b[1]);
> s.t. c4 : x <= xobs - cobs + big_number * b[1];
>
> # b[2] = 0 if x is to the right of xobs
> s.t. c5 : x <= xobs + cobs + big_number * (1 - b[2]);
> s.t. c6 : x >= xobs + cobs - big_number * b[2];
>
> # x must be at least to the right or to the left
> s.t. c7 : sum{j in 1..2} b[j] <= 1;
>
> solve;
>
> display xobs;
> display cobs;
> display x;
> display b;
>
> end;
--
Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de