Group Constraints for FMINCON

조회 수: 1 (최근 30일)
Tommaso Belluzzo
Tommaso Belluzzo 2020년 4월 26일
편집: Tommaso Belluzzo 2020년 4월 26일
Hi all! I'm writing a model that needs to minimize 6 variables through FMINCON: o, a, b, w, kappa, gamma. The variable options is defined as follows:
optimset(optimset(@fmincon),'Diagnostics','off','Display','off','LargeScale','off','MaxSQPIter',1000,'TolFun',1e-6)
The variables are already subject to the following lower/upper boundaries:
  • o, a, b, w between 0 and Inf;
  • kappa, gamma strictly positive between (2 * options.TolCon) and Inf;
I need to ensure a few constraints are respected:
  • o, a, b, w must approximately sum to 1;
  • kappa * gamma must be approximately equal to 1;
If I didn't have to consider the last two variables, I would have probably used A and b parameters of FMINCON as follows:
A = [-eye(3); ones(1,3)];
b = [(zeros(3,1) + (2 * options.TolCon)); (1 - (2 * options.TolCon))];
But going for that approach with two distinct constraints (an additive one and a multiplicative one) is pretty weird and I really have no clue about how to set A and b.
It seems that the nonlcon parameter may be what I'm looking for, but it's unclear to me how to formulate it properly.
Thanks!

채택된 답변

John D'Errico
John D'Errico 2020년 4월 26일
Approximately equals is NOT an equality constraint.
But you can write it as TWO inequality constraints. So if you want kappa*gamm approximately equal to 1, then that means you want the product to be within some given tolerance of 1. That is:
kappa*gamm >= 1 - tol
kappa*gamm <= 1 + tol
You can then swap the inequality direction on the first constraint by multiplying by -1.
-kappa*gamm <= -(1 - tol)
Note my use of gamm as a variable name, instead of gamma. Since there is a function called gamma that is often quite useful, I strongly suggest not using a variable named gamma.
  댓글 수: 1
Tommaso Belluzzo
Tommaso Belluzzo 2020년 4월 26일
편집: Tommaso Belluzzo 2020년 4월 26일
Thanks for your answer. May I kindly as you how I can implement this on the point of view of Matlab code?
I think I have to write a nonlcon function like this?
function [c,ceq] = my_nonlcon(x,options)
kappa = x(5);
gamm = x(6);
kg = kappa * gamm;
c1 = kg - (1 - (2 * options.TolCon));
c2 = kg - (1 + (2 * options.TolCon));
c = [c1; c2];
ceq = [];
end
Together with A and b contraints formulated as follows:
A = [[-eye(3) zeros(3)]; [ones(1,4) zeros(1,2)]; zeros(2,6)];
b = [(zeros(3,1) + (2 * options.TolCon)); (1 - (2 * options.TolCon)); zeros(2,1)];
Am I right?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by