fmincon: any way to enforce linear inequality constraints at intermediate iterations?

131 visualizaciones (últimos 30 días)
I am solving an optimization problem with the interior-point algorithm of fmincon.
My parameters have both lower and upper bounds and linear inequality constraints.
A_ineq = [1 -1 0 0 0;
-1 2 -1 0 0;
0 -1 2 -1 0;
0 0 -1 2 -1;
0 0 0 1 -1];
b_ineq=[0 0 0 0 0];
I observed that fmincon satisfies, of corrse, the bounds at all iterations but not the linear inequality constraints.
However, the linear inequality constraints are crucially important in my case. If violated, my optimization problem can not be solved.
Is there anything one can do to ensure that linear inequality constraints are satisfied at intermediate iterations?
  6 comentarios
SA-W
SA-W el 2 de Mzo. de 2023
Scaling the matrix A_ineq by 1e4 or any other large value really helps in my case to (in a least-squares sense) enforce the linear constraints at intermediate iterations.
Matt J
Matt J el 6 de Mayo de 2023
Editada: Matt J el 6 de Mayo de 2023
I'd like to point out that it violates the theoretical assumptions of fmincon, and probably all the Optimization Toolbox solvers as well, when the domain of your objective function and constraints is not an open subset of . If you forbid evaluation outside the closed set defined by your inequality constraints, that is essentially the situation you are creating. It's not entirely clear what hazards this creates in practice, but it might mean one of the Global Optimization Toolbox solvers might be more appropriate.

Iniciar sesión para comentar.

Respuesta aceptada

Matt J
Matt J el 5 de Mayo de 2023
Editada: Matt J el 23 de Mayo de 2023
Within your objective function, project the current x onto the constrained region using quadprog,
fun=@(x) myObjective(x, A_ineq,b_ineq,lb,ub);
x=fmincon(fun, x0,[],[],[],[],[],lb,ub,options)
function fval=myObjective(x, A_ineq,b_ineq,lb,ub)
C=speye(numel(x));
x=lsqlin(C,x,A_ineq,b_ineq,[],[],lb,ub); %EDIT: was quadprog by mistake
fval=...
end
  47 comentarios
SA-W
SA-W hace alrededor de 13 horas
I don't know if that helps you choose your tolerance, but maybe it will.
Not sure how it might help, but normalizing the rows of Aineq is in either case a good idea if different constraint sets (e.g. f>=0 and f''>=0) are assembled into Aineq to weight the different sets equally. Makes sense to formulate it like that?
Another hyperparameter is the weighting factor associated with the projection residual:
zp = lsqlin(I, z, Aineq, bineq, [], [], [], [], [], options);
projRes = zp-z;
fval = fval + weight * norm(projRes).^2
Usually, this weight is chosen on a case to case basis and has the purpose to balance/weight different contributions to the residuals.
In our case, the value we assign to "weight" does not really matter as the solution is characterized by "procRes = 0". So it may affect the path taken to the solution, but it should affect the solution itself, right?
Matt J
Matt J hace alrededor de 4 horas
but it should [Ed. not] affect the solution itself, right?
I dont think it should, no.

Iniciar sesión para comentar.

Más respuestas (2)

Shubham
Shubham el 5 de Mayo de 2023
Hi SA-W,
Yes, there are a few options you can try to ensure that the linear inequality constraints are satisfied at intermediate iterations of the interior-point algorithm in fmincon:
  1. Tighten the tolerances: By tightening the tolerances in the fmincon options, you can force the algorithm to take smaller steps and converge more slowly, but with higher accuracy. This may help to ensure that the linear inequality constraints are satisfied at all intermediate iterations.
  2. Use a barrier function: You can try using a barrier function to penalize violations of the linear inequality constraints. This can be done by adding a term to the objective function that grows very large as the constraints are violated. This will encourage the algorithm to stay within the feasible region defined by the constraints.
  3. Use a penalty function: Similar to a barrier function, a penalty function can be used to penalize violations of the linear inequality constraints. However, instead of growing very large, the penalty function grows linearly with the degree of violation. This can be a more computationally efficient approach than a barrier function.
  4. Use a combination of methods: You can try using a combination of the above methods to ensure that the linear inequality constraints are satisfied at all intermediate iterations. For example, you could tighten the tolerances and use a penalty function or barrier function to further enforce the constraints.
It's important to note that these methods may increase the computational cost of the optimization problem, so it's important to balance the accuracy requirements with the available resources.

Matt J
Matt J el 5 de Mayo de 2023
Within your objective function, check if the linear inequalites are satsfied. If they are not, abort the function and return Inf. Otherwise, compute the output value as usual.
fun=@(x) myObjective(x, A_ineq,b_ineq);
x=fmincon(fun, x0,A_ineq,b_ineq,[],[],lb,ub,[],options)
function fval=myObjective(x, A_ineq,b_ineq)
if ~all(A_ineq*x<=b_ineq)
fval=Inf; return
end
fval=...
end

Categorías

Más información sobre Linear Least Squares en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by