A = [-1 -2 -2; ...
1 2 2];
b = [0;72];
x0 = [10;10;10];
f = @(x)-x(1) * x(2) * x(3);
opt2 = optimset('Display','final','Algorithm','active-set','OutputFcn', @custom_output);
fmincon(f,x0,A,b,[],[],[],[],[],opt2);
function stop = custom_output(~, optimValues, state)
stop = false;
header = [' Max Line search Directional First-order\n' ...
' Iter F-count f(x) constraint steplength derivative optimality Procedure\n'];
formatstr = '%5.0f %5.0f %12.6g %12.4g %12.3g %12.3g %12.3g %s %s';
switch state
case 'init'
fprintf(header);
case 'iter'
iter = optimValues.iteration;
funcCount = optimValues.funccount;
f = optimValues.fval;
con = optimValues.constrviolation;
laststep = optimValues.lssteplength;
grad = optimValues.gradient;
direcderiv = optimValues.directionalderivative;
fo = optimValues.firstorderopt;
hessUpdateMsg = optimValues.procedure;
fprintf(formatstr,iter,funcCount,f,con,laststep,direcderiv,fo,hessUpdateMsg);
fprintf('\n');
end
Best Answer