help-glpk
[Top][All Lists]

## [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 --------
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 and b 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 = 0 if x is to the left of xobs
s.t. c3 : x >= xobs - cobs - big_number * (1 - b);
s.t. c4 : x <= xobs - cobs + big_number *      b;

# b = 0 if x is to the right of xobs
s.t. c5 : x <= xobs + cobs + big_number * (1 - b);
s.t. c6 : x >= xobs + cobs - big_number *      b;

# 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;

```