Can fmincon find corner solutions?
8 次查看(过去 30 天)
显示 更早的评论
I found a problem I could not really understand with fmincon. When the optimal solution is x=0 for a function under a contraint that x>=0, fmincon returns 2.0000e-08. It does not equal 0, though very close to. I wondered why it happenend and how I can get the correct result which is 0 instead of 2.0000e-08.
The example below is simple, but it shows the problem.
-------------script1: set up function
function cor = corners(ivm);
cor=ivm
end
-------------script2: use fmincon
fun = @(ivm)corners(ivm);
problem = createOptimProblem('fmincon','x0',0,...
'objective',fun,'lb',0,'ub',[]);
[cx,fval,exitflag,output,lambda,grad,hessian] = fmincon(problem)
-------------the results I get:
Local minimum found that satisfies the constraints.
Optimization completed because the objective function is non-decreasing in
feasible directions, to within the default value of the optimality tolerance,
and constraints are satisfied to within the default value of the constraint tolerance.
<stopping criteria details>
cx =
2.0000e-08
fval =
2.0000e-08
exitflag =
1
output =
struct with fields:
iterations: 7
funcCount: 17
constrviolation: 0
stepsize: 1.9739e-06
algorithm: 'interior-point'
firstorderopt: 2.0000e-08
cgiterations: 0
message: 'Local minimum found that satisfies the constraints.↵↵Optimization completed because the objective function is non-decreasing in ↵feasible directions, to within the default value of the optimality tolerance,↵and constraints are satisfied to within the default value of the constraint tolerance.↵↵Stopping criteria details:↵↵Optimization completed: The relative first-order optimality measure, 1.999988e-08,↵is less than options.OptimalityTolerance = 1.000000e-06, and the relative maximum constraint↵violation, 0.000000e+00, is less than options.ConstraintTolerance = 1.000000e-06.↵↵Optimization Metric Options↵relative first-order optimality = 2.00e-08 OptimalityTolerance = 1e-06 (default)↵relative max(constraint violation) = 0.00e+00 ConstraintTolerance = 1e-06 (default)'
lambda =
struct with fields:
eqlin: [0×1 double]
eqnonlin: [0×1 double]
ineqlin: [0×1 double]
lower: 1.0000
upper: 0
ineqnonlin: [0×1 double]
grad =
1
hessian =
6.4000e-05
-------------when I clicked "stopping criteria details", I get:
Optimization completed: The relative first-order optimality measure, 1.999988e-08,
is less than options.OptimalityTolerance = 1.000000e-06, and the relative maximum constraint
violation, 0.000000e+00, is less than options.ConstraintTolerance = 1.000000e-06.
Optimization Metric Options
relative first-order optimality = 2.00e-08 OptimalityTolerance = 1e-06 (default)
relative max(constraint violation) = 0.00e+00 ConstraintTolerance = 1e-06 (default)
-------------possible reasons I am thinking of:
- fmincon can't identify corner solutions properly
- something to do with one of the tolerances
- the gradient at x=0 is not 0.
It looks like the reasons are shown in the command window, but I couldn't really understand it. I would appreciate your help and detailed explanations. Thanks!
5 个评论
John D'Errico
2019-6-24
编辑:John D'Errico
2019-6-24
Yes. You absolutely NEED a symbolic tool to find an exact solution. What is not clear is if your problem has an analytical solution, since we do not see the problem itself.
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!