Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
NaN issue. Formulation of the Binary Integer Programming Problem

Subject: NaN issue. Formulation of the Binary Integer Programming Problem

From: Liana

Date: 24 Mar, 2011 18:55:19

Message: 1 of 2

Hello All,

I'm interested in how the BIP problem can be formulated for the following case. Let's say there is Delaunay Triangulation model of the 2D space. I'd like to find a shortest channel of triangles from the initial position to the goal position. I need to codify the following type of inequality constraints, where xi is the i-th triangle (0 - not selected; 1 - selected) and sum(xij) is the sum of adjacent triangles:

x1 + sum(x1j) <= 3

The problem is that sometimes xij can be equal to NaN meaning that the ith triangle has only 2 adjacent triangles instead of 3. I'm trying to use 'isnan' function to check if x is equal to NaN:

A = [x(1,1) + x(~isnan(neighbors(handles.dt, 1)),1)]

But it does not work. Please give me some advice on how to formulate such kind of constraints.

Thanks a lot.

Subject: NaN issue. Formulation of the Binary Integer Programming Problem

From: Liana

Date: 24 Mar, 2011 20:44:05

Message: 2 of 2

"Liana" wrote in message <img42n$kbr$1@fred.mathworks.com>...
> Hello All,
>
> I'm interested in how the BIP problem can be formulated for the following case. Let's say there is Delaunay Triangulation model of the 2D space. I'd like to find a shortest channel of triangles from the initial position to the goal position. I need to codify the following type of inequality constraints, where xi is the i-th triangle (0 - not selected; 1 - selected) and sum(xij) is the sum of adjacent triangles:
>
> x1 + sum(x1j) <= 3
>
> The problem is that sometimes xij can be equal to NaN meaning that the ith triangle has only 2 adjacent triangles instead of 3. I'm trying to use 'isnan' function to check if x is equal to NaN:
>
> A = [x(1,1) + x(~isnan(neighbors(handles.dt, 1)),1)]
>
> But it does not work. Please give me some advice on how to formulate such kind of constraints.
>
> Thanks a lot.

I see that ~isnan() returns 0 or 1, therefore x(~isnan(...)) does not work correctly. Let me give one example:
x =
   9 16 NaN
   12 10 11
Now I need to change this code (A = [x(1,1) + x(~isnan(neighbors(handles.dt, 1)),1)]) in such a way that NaN cell is simply skipped.

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us