Re: fmincon
- From: "Paul Kerr-Delworth" <Paul.Kerr-Delworth@xxxxxxxxxxxxxxx>
- Date: Fri, 17 Oct 2008 12:44:28 +0100
Hi Alexander,
I think you could use the area of intersection as a measure of whether two
rectangles intersect. Given two rectangles with x-coordinates L, R and
y-coordinates B, T, (I think - you'll need to check!) the following code
calculates the area of intersection of the rectangles if they intersect and
returns a negative A if they do not.
L = max(L1, L2);
R = min(R1, R2);
B = max(B1, B2);
T = min(T1, T2);
A = (R-L)*(T-B);
if R-L < 0 && T-B < 0
A = -A;
end
However, this code still suffers from the issue that John raised. That is,
this code will return zero if the two rectangles intersect at a point or
line - an optimization routine would consider this to be a feasible
solution.
Hope this helps
Best regards,
Paul
"Alexander Blumin" <bluminalex@xxxxxxxxx> wrote in message
news:gd85nn$2gq$1@xxxxxxxxxxxxxxxxxxxxx
Yes,you're right but could be some way you think about to require disjoint
rectangles?
According to case you mention its to require all the rectangle bellow left
x-bound of second one or entire rectangle right after the right bound of
it. The same with y axis. Again i'am with some OR conditions.
Thanks,
Alex
"John D'Errico" <woodchips@xxxxxxxxxxxxxxxx> wrote in message
<gd841b$6qm$1@xxxxxxxxxxxxxxxxxx>...
"Alexander Blumin" <bluminalex@xxxxxxxxx> wrote in message
<gd823h$836$1@xxxxxxxxxxxxxxxxxx>...
Hi guys,
I'm working with fmincon on the following optimization problem:
Given a set of rectangles and bivariate normal distribution
i'd like to find the 'best' rectangles position and size.
'Best' here it means the resulted rectangle's union grasp more
probability.(My objective function is actually a double integral over
union of these recntangles).
Now finally the problem: At this stage i'd like to require a disjoint
rectangles in my constraints enequalities.
I don't find a way to do it. Simple way to say rectnagles does not
intersect is to say no vertex of one is inside another one. Now to say
point outside of rectangle is to require point.x outside the x range of
recntangle OR point.y outside the y range of recntangle. I don't know
how to implement this OR. This is logical and isn't continuous
constraint,isn't it?
Any help or thoughts are highly appriciated.
Worse, two rectangles can intersect even
if no point from either of the rects is
inside the other.
John
.
- Follow-Ups:
- Re: fmincon
- From: Matt
- Re: fmincon
- References:
- fmincon
- From: Alexander Blumin
- Re: fmincon
- From: John D'Errico
- Re: fmincon
- From: Alexander Blumin
- fmincon
- Prev by Date: for loop
- Next by Date: Re: Add fields to structure
- Previous by thread: Re: fmincon
- Next by thread: Re: fmincon
- Index(es):
Relevant Pages
|