lower bound violation in fmincon
8 views (last 30 days)
Show older comments
I'm trying to solve it with fmincon. but why lower bound i violate?
I've got these:
cc =
1.0e+03 *
Columns 1 through 9
0.0010 0.5665 -0.1271 0.3301 0.4055 0.0858 0.0245 -0.0587 -0.1697
Columns 10 through 18
-0.1403 -0.1990 -0.1432 0.0572 -0.2194 1.2516 -0.0240 -0.2349 -0.2138
Columns 19 through 24
-0.2138 -0.0471 -0.2324 -0.2330 -0.2320 -0.2330
and a warning also:
Warning: Length of lower bounds is < length(x); filling in missing lower bounds with -Inf.
> In checkbounds at 34
In fmincon at 332
In AA at 16
Warning: Length of upper bounds is < length(x); filling in missing upper bounds with +Inf.
> In checkbounds at 48
In fmincon at 332
In AA at 16
Warning: The default trust-region-reflective algorithm does not solve problems with the
constraints you have specified. FMINCON will use the active-set algorithm instead. For
information on applicable algorithms, see Choosing the Algorithm in the documentation.
> In fmincon at 500
In AA at 16
Warning: Your current settings will run a different algorithm (interior-point) in a future
release.
> In fmincon at 505
In AA at 16
Local minimum possible. Constraints satisfied.
fmincon stopped because the predicted change in the objective function
is less than the default value of the function tolerance and constraints
are satisfied to within the default value of the constraint tolerance.
<stopping criteria details>
0 Comments
Answers (1)
Star Strider
on 15 Aug 2014
Edited: Matt J
on 16 Aug 2014
Your bounding vectors have the be the same length as ‘cc’. You have to have a matching upper and lower bound for every element in cc.
The call to fmincon to constrain the individual parameter bounds to be between 0 and 1, and constrain the sum of the parameters to be between 0 and 1 should be:
A = [-ones(1,24); ones(1,24)];
b = [0; 1];
[cc,fval]=fmincon(objfcn,rand(1,24),A,b,[],[],zeros(1,24),ones(1,24))
5 Comments
Star Strider
on 16 Aug 2014
Thanks, Matt. Sleeping here (GMT-6) .
Maryamm, I misread your previous post, and thought you wanted: (0 < sum(cc) <= 1). If you want:
- The individual parameters (0 < cc <= 1) and,
- Sum of the parameters sum(cc) = 1,
The code becomes (with Matt J’s suggestion for cc0):
Aeq = ones(1,24); % Equality Constraints
beq = 1; % Equality Constraints
cc0=rand(1,24);
cc0=cc0/sum(cc0); % Initial Guess
[cc,fval]=fmincon(objfcn,rand(1,24),[],[],Aeq,beq,zeros(1,24),ones(1,24))
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!