MATLAB Answers


Understanding the syntax of the minimax constraint problem

Asked by Clarisha Nijman on 29 Nov 2018
Latest activity Commented on by Clarisha Nijman on 30 Nov 2018
Dear all I am trying to solve a minimax constraint problem, where the objective function is an absolute function.
Given the data set A with 3 variables,x(1), x(2) and x(3) and an unknown error term x(4):
0.0027 0.0025 0.0025
0.0028 0.0030 0.0029
0.0030 0.0031 0.0031
0.0031 0.0031 0.0032
0.0032 0.0032 0.0033
0.0033 0.0033 0.0034
0.0035 0.0035 0.0035
0.0036 0.0032 0.0036
0.0031 0.0037 0.0037
I define the absolute function of the minimax problem:
function F = maximizefunc(A)
for i=1:size(A,1)
% Make a starting guess at solution
x0 = 0.1*rand(4,1);
and apply the code given in on of the last examples on the matlab site (
options = optimoptions('fminimax','AbsoluteMaxObjectiveCount',5); % Minimize abs. values
[x,fval] = fminimax(@maximizefunc,x0,...
But I am getting only errors saying:
Function definitions in a script must appear at the end of the file.
Move all statements after the "maximizefunc" function definition to before the function definition.
Error in fminimax (line 351)
user_f = feval(funfcn{3},x,varargin{:});
Does anyone have a suggestion for me? I do not really understand how the option function should be constructed. Can somebody give me some feedback pls.
Thank u in advance


Sign in to comment.

1 Answer

Answer by Alan Weiss
on 29 Nov 2018

Your problem is that you want to include a data matrix A as extra data, but you are doing it incorrectly. See Passing Extra Parameters. Your function should look like this:
function F = maximizefunc(x,A)
% code here
Then you call it like this:
[args] = fminimax(@(x)maximizefunc(x,A),[more args])
Alan Weiss
MATLAB mathematical toolbox documentation

  1 Comment

Would I get the same result as in example below? (
Find values of x that minimize the maximum value of
[f1(x), f2(x), f3(x), f4(x), f5(x)]
First, write a file that computes the five functions at x.
function f = myfun(x)
f(1)= 2*x(1)^2+x(2)^2-48*x(1)-40*x(2)+304; % Objectives
f(2)= -x(1)^2 - 3*x(2)^2;
f(3)= x(1) + 3*x(2) -18;
f(4)= -x(1)- x(2);
f(5)= x(1) + x(2) - 8;
Next, invoke an optimization routine.
x0 = [0.1; 0.1]; % Make a starting guess at solution
[x,fval] = fminimax(@myfun,x0);
The only difference is that my objective function is an absolute fucntion, so I combine the next instruction on that same wegpage with more instructions above.
You can solve problems of the form
min x max i |Fi(x)|
by using the AbsoluteMaxObjectiveCount option; see Notes.
The information needed for the set of F functions can be retrieved from the given data set A,

Sign in to comment.