Re: fmincon
- From: "Alexander Blumin" <bluminalex@xxxxxxxxx>
- Date: Fri, 17 Oct 2008 18:44:02 +0000 (UTC)
Thanks,firsl of all.
I'll check this option,but i don't absolutely understand one nuance: The constaints in fmincon are continuous functions,linear and not linear but continuous.
Here when you subsititute into constraint the results of function that calculated using pure logic if\else,you jump from zero result to other result not in continuous manner i think. Isn't it a problem theoretically?
I probably missunderstand something,could you clarify it please?
Thanks a lot,
Alex
"Bruno Luong" <b.luong@xxxxxxxxxxxxxxxxxxxx> wrote in message <gdahni$fcn$1@xxxxxxxxxxxxxxxxxx>...
"Alexander Blumin" <bluminalex@xxxxxxxxx> wrote in message <gdafam$kfu$1@xxxxxxxxxxxxxxxxxx>....
Thanks for response.
The rectangles are alligned to axes (i.e not rotated) so the code of calculating the intersection is o'k i guess.
Excuse me for maybe stupid question: -A as sign to empty intersection is given to implement say constraint c(x)< 0 ?
Thanks,
Alex
I don't quite get what is the problem to compute the surface of the intersection of two rectangles. It takes me 2 minutes to program one like this:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function S = comsurf(R1, R2)
% Return the intersection surface of rectangles R1 and R2
%
% R of the form = [xa ya xb yb], with (xa,ya) and (xb,yb) are two
% opposite corners
S = comseg(R1([1 3]),R2([1 3]))*comseg(R1([2 4]),R2([2 4]));
end
function l = comseg(I1, I2)
I1 = sort(I1(:));
I2 = sort(I2(:));
if I1(2)<I2(1) || I2(2)<I1(1)
l = 0;
else
Is = sort([I1; I2]);
l = Is(3)-Is(2);
end
end
%%%%%%%%%%%%%%%%%%
Then just plug into fmincon with the constraint
c12 := comsurf(R1, R2) <= 0;
c13 := comsurf(R1, R3) <= 0;
c23 := comsurf(R2, R3) <= 0;
% ...
% Do it for all couple of mutual rectangles
These are set continue constraints. You can transform it into a equivalent linear constraints (just seat down and go through all the case with "sort"), however the equivalent number of linear equations should be much larger.
Bruno
- Follow-Ups:
- Re: fmincon
- From: Bruno Luong
- Re: fmincon
- References:
- fmincon
- From: Alexander Blumin
- Re: fmincon
- From: John D'Errico
- Re: fmincon
- From: Alexander Blumin
- Re: fmincon
- From: Paul Kerr-Delworth
- Re: fmincon
- From: Matt
- Re: fmincon
- From: Alexander Blumin
- Re: fmincon
- From: Bruno Luong
- fmincon
- Prev by Date: Re: Error message when opening a cell from array editor
- Next by Date: Re: image acquisition device problem
- Previous by thread: Re: fmincon
- Next by thread: Re: fmincon
- Index(es):
Relevant Pages
|
Loading