From: diana van dijk on
Hi,

I'm stuck with a problem in my fmincon optimization. To be specific, it concerns the lower and upper bound. I want to constrain the optimization by putting constraints on the bounds. But in some combinations of the 3 state variables (i,j,m) the lower bound exceeds the upper bound. This makes sense mathematically, but it's just the way I need to set the bounds. In the cases of exceeding bounds I remove the constraints and set the bounds back to the original case. But there should be a way to be able to deal with this in a more sophisticated way (still making the area to optimize over more rigid, in some way or another) so that the bounds will never exceed one another.
Any suggestion will be very helpful,
Diana

CODE:
ivec=linspace(.1,2,10);
jvec=linspace(.05,1,10);
mvec=linspace(.05,2,10);

for a = 0:0.01:1
for I = 1:length(ivec)
for J = 1:length(jvec)
for M = 1:length(mvec)

i = ivec(I);
j = jvec(J);
m = mvec(M);

LB_NoConstraint = -m;
LB_WithConstraint = max( -m, -m*(1-a) );

UB_NoConstraint = min(i,j)-m;
UB_WithConstraint = min( min(i,j)-m, (min(i,j)-m)*(1+a) );

if ( abs(LB_WithConstraint > UB_WithConstraint) > beta )
disp 'LB greater than UB'
LB_WithConstraint = LB_NoConstraint;
UB_WithConstraint = UB_NoConstraint;
end
end
end
end
end
From: Steven Lord on

"diana van dijk" <matlab_di(a)yahoo.com> wrote in message
news:hth65k$gbk$1(a)fred.mathworks.com...
> Hi,
>
> I'm stuck with a problem in my fmincon optimization. To be specific, it
> concerns the lower and upper bound. I want to constrain the optimization
> by putting constraints on the bounds. But in some combinations of the 3
> state variables (i,j,m) the lower bound exceeds the upper bound. This
> makes sense mathematically, but it's just the way I need to set the
> bounds. In the cases of exceeding bounds I remove the constraints and set
> the bounds back to the original case. But there should be a way to be able
> to deal with this in a more sophisticated way (still making the area to
> optimize over more rigid, in some way or another) so that the bounds will
> never exceed one another.

Skimming through your code, it looks like you're trying to introduce a
constraint like:

firstVar + secondVar + thirdVar <= m

If so, you should not implement this using the lower and upper bound. Use
the linear constraint inputs A, b, Aeq, and beq for this purpose instead.
For example, the equivalent of the above constraint is:

A = [1 1 1];
b = m;

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com


From: diana van dijk on
Thanks for the advice. I do have an another question:
If my control variable is CV, where I wrote in LB UB form:

LB =< CV =< UB
-m =< CV =< min(i,j)-m %in the original case
-m * (1+a) =< CV =< (min(i,j)-m) * (1-a) %in the constrained case (tighter bounds)

Then, writing it in linear constraint form:

CV =< (min(i,j)-m) * (1-a)
CV >= -m * (1+a) --> -CV =< m * -(1+a)

I'm a bit confused as what A, x and b are in this case. I'm thinking:

A = (1-a) and -(1+a) A = [1 1 -a; 1 -1 -a]
x = CV and -CV x = [CV; -CV]
b = (min(i,j)-m) and m b = [min(i,j)-m; m]

Then, for:
CV =< (min(i,j)-m) * (1-a)
this would be: x =< bA
to get: Ax =< b
(1/A)x =< b
(1/(1-a))CV =< min(i,j)-m
(The same procedure for -CV)

Does it make sense that x is the control variable that is optimized with fmincon and that b consists of the state variables over which iteration takes place?
Any enlightening is appreciated,
Diana




"diana van dijk" <matlab_di(a)yahoo.com> wrote in message <hth65k$gbk$1(a)fred.mathworks.com>...
> Hi,
>
> I'm stuck with a problem in my fmincon optimization. To be specific, it concerns the lower and upper bound. I want to constrain the optimization by putting constraints on the bounds. But in some combinations of the 3 state variables (i,j,m) the lower bound exceeds the upper bound. This makes sense mathematically, but it's just the way I need to set the bounds. In the cases of exceeding bounds I remove the constraints and set the bounds back to the original case. But there should be a way to be able to deal with this in a more sophisticated way (still making the area to optimize over more rigid, in some way or another) so that the bounds will never exceed one another.
> Any suggestion will be very helpful,
> Diana
>
> CODE:
> ivec=linspace(.1,2,10);
> jvec=linspace(.05,1,10);
> mvec=linspace(.05,2,10);
>
> for a = 0:0.01:1
> for I = 1:length(ivec)
> for J = 1:length(jvec)
> for M = 1:length(mvec)
>
> i = ivec(I);
> j = jvec(J);
> m = mvec(M);
>
> LB_NoConstraint = -m;
> LB_WithConstraint = max( -m, -m*(1-a) );
>
> UB_NoConstraint = min(i,j)-m;
> UB_WithConstraint = min( min(i,j)-m, (min(i,j)-m)*(1+a) );
>
> if ( abs(LB_WithConstraint > UB_WithConstraint) > beta )
> disp 'LB greater than UB'
> LB_WithConstraint = LB_NoConstraint;
> UB_WithConstraint = UB_NoConstraint;
> end
> end
> end
> end
> end
From: Steven Lord on

"diana van dijk" <matlab_di(a)yahoo.com> wrote in message
news:hthmps$4u4$1(a)fred.mathworks.com...
> Thanks for the advice. I do have an another question:
> If my control variable is CV, where I wrote in LB UB form:
>
> LB =< CV =< UB
> -m =< CV =< min(i,j)-m %in the original case

This is no longer linear, as the "bound" depends on min(i, j). For this you
would need a _nonlinear_ constraint function; see the FMINCON documentation
for a description of the NONLCON input argument.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com


From: Alan Weiss on
On 5/26/2010 10:06 AM, Steven Lord wrote:
> "diana van dijk"<matlab_di(a)yahoo.com> wrote in message
> news:hthmps$4u4$1(a)fred.mathworks.com...
>> Thanks for the advice. I do have an another question:
>> If my control variable is CV, where I wrote in LB UB form:
>>
>> LB =< CV =< UB
>> -m =< CV =< min(i,j)-m %in the original case
>
> This is no longer linear, as the "bound" depends on min(i, j). For this you
> would need a _nonlinear_ constraint function; see the FMINCON documentation
> for a description of the NONLCON input argument.
>

I think you can just use two bounds instead of a "min":
CV =< i - m
CV =< j - m

Put both in the linear constraint, and you will be assured that both are
satisfied, meaning the minimum of the two is satisfied.

Alan Weiss
MATLAB mathematical toolbox documentation