## How to continue without solution min max constraint problem.

### Clarisha Nijman (view profile)

on 14 Dec 2018
Latest activity Commented on by Clarisha Nijman

on 15 Dec 2018

### Matt J (view profile)

Hello,
Solving a min max constraint problem in matlab,is a part/function of my whole code. This function finds the optimal linear combination of the distributions, x and y such that it approximates z very good. The problem is that the code is terminated if the optimization problem cannot be solved. In that case I would like to use choose my own values for the optimal parameters.
So I wrote this part in the code:
if sum(OptArgum(1:2))<1
OptArgum(1)=0.5;
OptArgum(2)=0.5;
end
But It does not work. So now I am left with two questions:
1) Can you give me some suggestion for better code?
2) How can I add arguments to the code such as 'MaxFunEvals', 1000, 'Maxiter', 1000, such that the code is not terminated easily?
This is the code of my function:
function[OptArgum,v]=ModelParametersMinMax (x, y, z)
%This function finds the optimal linear combination of the distributions, x and y such that it approximates z very good. z=a*x+(1-a)*y
%input
% x =The pdf vector of process x
% y =The pdf vector of process y
% z =The pdf vector of all processes together
%output
%OptArgum=A vector that consist of three entrees all coefficients for x,y and z
%v =A linear combination of the x and y such that v can be approximated by: a*x+(1-a)*y
%Construction of the constraint matrix
Aleq=[];
bleq=[];
Aeq=[1 1 0];
beq=1;
%bound of the variables
lb=[0 0 0];
ub=[];
x0=0.1*rand(3,1);%initial guess
Cs=[x y -z];%coefficients of the objective function
% Solving the minmax constraint problem
[OptArgum, ~] = fminimax(@(x) Cs*x,x0,Aleq,bleq(:),Aeq,beq,lb,ub);
if sum(OptArgum(1:2))<1
OptArgum(1)=0.5;
OptArgum(2)=0.5;
end
v=OptArgum(1)*xPred + OptArgum(2)*xEstimatedRate;%approximation for z
end

Matt J

### Matt J (view profile)

on 14 Dec 2018
Please elaborate on "does not work". What's wrong with it?

on 14 Dec 2018
Edited by Matt J

### Matt J (view profile)

on 14 Dec 2018

options=optimoptions(@fminimax,__________);
% Solving the minmax constraint problem
[OptArgum, ~,~,exitflag] = fminimax(@(x) Cs*x,x0,Aleq,bleq(:),Aeq,beq,lb,ub,[],options);
if exitflag<=0
OptArgum(1)=0.5;
OptArgum(2)=0.5;
end

Clarisha Nijman

### Clarisha Nijman (view profile)

on 15 Dec 2018
Thanks Matt,
This is exactly what I need, if an optimal solution is not found the whole code stops running, but now I know how to prevent that. However, I have to study the exitflag options better.
kind regards