[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-glpk] [Fwd: Find nearest point]
From: |
Andrew Makhorin |
Subject: |
[Help-glpk] [Fwd: Find nearest point] |
Date: |
Wed, 15 Jun 2011 14:23:16 +0400 |
-------- Forwarded Message --------
From: address@hidden
Reply-To: address@hidden
To: address@hidden
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;
- [Help-glpk] [Fwd: Find nearest point],
Andrew Makhorin <=