Error in fmincon: infinite loop?

4 visualizaciones (últimos 30 días)
Arnoud
Arnoud el 13 de Oct. de 2014
Respondida: Alan Weiss el 13 de Oct. de 2014
I minimize a function with fmincon. Just a nice bounded smooth function with bounded support.... But.... for some initial values, fmincon just refuses to give an answer! It seems to be stuck in some infinite loop.... What is happening?? (I use Matlab version R2013a).
clc; close all; clear all;
%define function
data = [ 8.6000 1.0000
18.2000 1.0000
6.8000 1.0000
17.7000 0
12.2000 1.0000];
pricedata = data(:,1);demanddata = data(:,2);
mu = @(price, theta, beta0, beta1) ((1 ./ (1 + exp(-ones(max(size(price)),1) * beta0' - price * beta1'))) * theta);
minusloglikelihood = @(x) - demanddata'* log(mu(pricedata, [x(5);1-x(5)], x(1:2), x(3: 4))) - (1-demanddata)'* log(1-mu(pricedata, [x(5); 1-x(5)],x(1:2), x(3: 4)));
%optimize for different starting values
options = optimoptions('fmincon','Display', 'off', 'Algorithm','active-set');
%For this starting value I get an answer
x0 = [10.5; 10.5; -1.05;-1.05; 0.705]
[X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] = fmincon( minusloglikelihood, x0, [],[],[],[],[1;1;-2;-2;0],[20;20;-0.1;-0.1;1],[],options)
%For this starting value I don't get an answer
x0 = [10.5; 10.5; -1.05;-1.05; 0.706]
[X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] = fmincon( minusloglikelihood, x0, [],[],[],[],[1;1;-2;-2;0],[20;20;-0.1;-0.1;1],[],options)

Respuestas (1)

Alan Weiss
Alan Weiss el 13 de Oct. de 2014
I suggest that you set iterative display instead of turning the display off, and I also suggest that you use the interior-point algorithm (or sqp) instead of active-set.
For further suggestions, see When the Solver Fails.
Alan Weiss
MATLAB mathematical toolbox documentation

Categorías

Más información sobre Solver Outputs and Iterative Display en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by