%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%
%     This is an example call of MIDACO 6.0
%     -------------------------------------
%
%     MIDACO solves Multi-Objective Mixed-Integer Non-Linear Problems:
%
%
%      Minimize     F_1(X),... F_O(X)  where X(1,...N-NI)   is CONTINUOUS
%                                      and   X(N-NI+1,...N) is DISCRETE
%
%      subject to   G_j(X)  =  0   (j=1,...ME)      equality constraints
%                   G_j(X) >=  0   (j=ME+1,...M)  inequality constraints
%
%      and bounds   XL <= X <= XU
%
%
%     The problem statement of this example is given below. You can use 
%     this example as template to run your own problem. To do so: Replace 
%     the objective functions 'F' (and in case the constraints 'G') given 
%     here with your own problem and follow the below instruction steps.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
function example
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%   MAIN PROGRAM   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 key = '************************************************************';   
 problem.func = @problem_function; % Call is [f,g] = problem_function(x)        
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Step 1: Problem definition     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  
% STEP 1.A: Problem dimensions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
problem.o  = 1; % Number of objectives
problem.n  = 10; % Number of variables (in total)
problem.ni = 10; % Number of integer variables (0 <= ni <= n)
problem.m  = 10; % Number of constraints (in total)
problem.me = 0; % Number of equality constraints (0 <= me <= m)
     
% STEP 1.B: Lower and upper bounds 'xl' & 'xu'  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
problem.xl   =   0 * ones(1,problem.n);
problem.xu   = 200 * ones(1,problem.n);

% STEP 1.C: Starting point 'x'  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
problem.x  = problem.xl; % Here for example: 'x' = lower bounds 'xl'
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Step 2: Choose stopping criteria and printing options    %%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% STEP 2.A: Stopping criteria 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
option.maxeval  = 1000000;    % Maximum number of function evaluation (e.g. 1000000)
option.maxtime  = 60*60*24; % Maximum time limit in Seconds (e.g. 1 Day = 60*60*24)

% STEP 2.B: Printing options  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
option.printeval  = 100;  % Print-Frequency for current best solution (e.g. 1000)
option.save2file  = 1;     % Save SCREEN and SOLUTION to TXT-files [ 0=NO/ 1=YES]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Step 3: Choose MIDACO parameters (FOR ADVANCED USERS)    %%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

option.param( 1) =  0;  % ACCURACY  
option.param( 2) =  0;  % SEED      
option.param( 3) =  -1033.1999999;  % FSTOP
option.param( 4) =  0;  % ALGOSTOP
option.param( 5) =  0;  % EVALSTOP  
option.param( 6) =  0;  % FOCUS
option.param( 7) =  0;  % ANTS
option.param( 8) =  0;  % KERNEL
option.param( 9) =  0;  % ORACLE    
option.param(10) =  0;  % PARETOMAX   
option.param(11) =  0;  % EPSILON   
option.param(12) =  0;  % BALANCE
option.param(13) =  0;  % CHARACTER 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Step 4: Choose Parallelization Factor   %%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

option.parallel = 0;  % Serial: 0 or 1, Parallel: 2,3,4,5,6,7,8...  

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%   Call MIDACO solver   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[ solution ] = midaco( problem, option, key);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%   End of Example    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
end


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%   OPTIMIZATION PROBLEM   %%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [ f, g ] = problem_function( x )
    
  i1 = x(1);
  i2 = x(2);
  i3 = x(3);
  i4 = x(4);
  i5 = x(5);
  i6 = x(6);
  i7 = x(7);
  i8 = x(8);
  i9 = x(9);
  i10 = x(10);

  f = 7*SQR(i1) + 6*SQR(i2) + 37.6*i1 + 19.6*i2 ...
    + 8*SQR(i3) - 6*i3*i1 + 4*i3*i2 - 5.6*i3 ...
    + 6*SQR(i4) + 2*i4*i1 + 2*i4*i3 - 26*i4 ...
    + 7*SQR(i5) - 4*i5*i1 - 2*i5*i2 - 6*i5*i3 ...
    - 125*i5 + 4*SQR(i6) + 2*i6*i1 - 4*i6*i2 ...
    - 4*i6*i3 - 2*i6*i4 + 6*i6*i5 - 79.6*i6 ...
    + 6*SQR(i7) - 2*i7*i1 - 6*i7*i2 - 2*i7*i3 ...
    + 4*i7*i5 + 4*i7*i6 - 104.2*i7 + 7*SQR(i8) ...
    - 4*i8*i1 - 2*i8*i2 + 6*i8*i3 + 4*i8*i4 ...
    - 4*i8*i5 - 2*i8*i6 + 4*i8*i7 - 4.6*i8 ...
    + 8*SQR(i9) - 2*i9*i1 - 4*i9*i2 + 4*i9*i3 ...
    + 4*i9*i4 - 4*i9*i5 - 4*i9*i6 + 8*i9*i7 ...
    + 4*i9*i8 - 22.8*i9 + 6*SQR(i10) - 4*i10*i1 ...
    - 6*i10*i2 + 2*i10*i3 - 4*i10*i4 ...
    + 2*i10*i5 ...
    + 2*i10*i6 - 2*i10*i7 - 4*i10*i8 ...
    - 2*i10*i9 ...
    + 9*i10;

  g(1) = (-9*SQR(i1)) - 10*i1*i2 - 8*SQR(i2) ...
    - 5*SQR(i3) ...
    - 6*i3*i1 - 10*i3*i2 - 7*SQR(i4) ...
    - 10*i4*i1 ...
    - 6*i4*i2 - 2*i4*i3 - 2*i5*i2 - 7*SQR(i5) ...
    - 6*i6*i1 - 2*i6*i2 - 2*i6*i4 - 5*SQR(i6) ...
    + 6*i7*i1 + 2*i7*i2 + 4*i7*i3 + 2*i7*i4 ...
    - 4*i7*i5 + 4*i7*i6 - 8*SQR(i7) - 2*i8*i1...
    - 6*i8*i2 - 2*i8*i3 + 6*i8*i5 - 2*i8*i7 ...
    - 6*SQR(i8) + 2*i9*i3 - 4*i9*i4 + 8*i9*i5 ...
    + 4*i9*i6 - 6*i9*i8 - 6*SQR(i9) ...
    + 2*i10*i1 ...
    + 2*i10*i2 - 2*i10*i4 + 2*i10*i5 ...
    - 2*i10*i6 ...
    - 2*i10*i8 - 6*i10*i9 - 8*SQR(i10) ...
    + 1930;
  g(2) = (-6*SQR(i1)) - 8*i1*i2 - 6*SQR(i2) ...
    - 4*SQR(i3) ...
    - 2*i3*i1 - 2*i3*i2 - 8*SQR(i4) + 2*i4*i1 ...
    + 10*i4*i2 - 2*i5*i1 - 6*i5*i2 + 6*i5*i4 ...
    + 7*SQR(i5) - 2*i6*i2 + 8*i6*i3 + 2*i6*i4 ...
    - 4*i6*i5 - 8*SQR(i6) - 6*i7*i1 ...
    - 10*i7*i2 ...
    - 2*i7*i3 + 10*i7*i4 - 10*i7*i5 ...
    - 8*SQR(i7) ...
    - 2*i8*i1 - 4*i8*i2 - 2*i8*i3 - 8*i8*i5 ...
    - 8*i8*i7 - 5*SQR(i8) - 2*i9*i1 - 2*i9*i2 ...
    + 4*i9*i6 + 2*i9*i7 - 6*SQR(i9) ...
    + 4*i10*i1 ...
    - 2*i10*i3 + 4*i10*i4 + 6*i10*i6 ...
    - 2*i10*i7...
    - 2*i10*i8 - 6*SQR(i10) + 3140;
  g(3) = (-9*SQR(i1)) - 6*SQR(i2) - 8*SQR(i3) ...
    + 2*i2*i1 ...
    + 2*i3*i2 - 6*SQR(i4) + 4*i4*i1 + 4*i4*i2 ...
    - 2*i4*i3 - 6*i5*i1 - 2*i5*i2 + 4*i5*i4 ...
    + 6*SQR(i5) + 2*i6*i1 + 4*i6*i2 - 6*i6*i4 ...
    - 2*i6*i5 - 5*SQR(i6) + 2*i7*i2 - 4*i7*i3...
    - 6*i7*i5 - 4*i7*i6 - 7*SQR(i7) - 2*i8*i1 ...
    + 4*i8*i3 + 2*i8*i4 - 4*SQR(i8) ...
    + 10*i9*i1 ...
    + 6*i9*i2 - 4*i9*i3 - 10*i9*i4 + 8*i9*i5 ...
    - 6*i9*i6 - 2*i9*i7 - 8*SQR(i9) ...
    - 4*i10*i2 ...
    + 2*i10*i3 + 4*i10*i4 + 6*i10*i5 ...
    + 2*i10*i7 ...
    - 2*i10*i8 + 2*i10*i9 - 7*SQR(i10) ...
    + 4*i10*i6 ...
    + 1600;
  g(4) = (-8*SQR(i1)) - 4*SQR(i2) - 9*SQR(i3) ...
    - 7*SQR(i4) - 2*i2*i1 - 2*i3*i1 - 4*i3*i2 ...
    + 6*i4*i1 + 2*i4*i2 - 2*i4*i3 - 6*i5*i1 ...
    - 4*i5*i2 - 2*i5*i3 + 6*i5*i4 + 6*SQR(i5) ...
    - 10*i6*i1 - 10*i6*i3 + 4*i6*i4 - 2*i6*i5 ...
    - 7*SQR(i6) + 6*i7*i1 - 2*i7*i2 - 2*i7*i3 ...
    + 6*i7*i5 + 2*i7*i6 - 6*SQR(i7) + 4*i8*i1 ...
    - 4*i8*i2 + 2*i8*i3 - 4*i8*i4 - 4*i8*i5 ...
    + 8*i8*i6 + 6*i8*i6 - 8*SQR(i8) - 4*i9*i1 ...
    + 4*i9*i2 + 6*i9*i3 - 2*i9*i4 + 2*i9*i6 ...
    + 8*i9*i7 - 4*i9*i8 - 10*SQR(i9) ...
    + 8*i10*i1 ...
    + 4*i10*i2 + 2*i10*i3 + 2*i10*i4 ...
    + 4*i10*i6 ...
    - 6*SQR(i10) + 1260;
  g(5) = 2*i2*i1 - 4*SQR(i1) - 5*SQR(i2) ...
    - 6*i3*i1 ...
    - 8*SQR(i3) - 2*i4*i1 + 6*i4*i2 - 2*i4*i3 ...
    - 6*SQR(i4) - 4*i5*i1 + 2*i5*i2 - 6*i5*i3 ...
    - 8*i5*i4 - 7*SQR(i5) + 4*i6*i1 - 4*i6*i2 ...
    + 6*i6*i3 + 4*i6*i5 - 7*SQR(i6) + 4*i7*i1 ...
    - 4*i7*i2 - 4*i7*i3 + 4*i7*i4 + 4*i7*i5 ...
    + 4*i7*i6 - 8*SQR(i7) - 2*i8*i1 + 4*i8*i4...
    + 2*i8*i6 + 2*i8*i7 - 4*SQR(i8) - 2*i9*i2 ...
    + 4*i9*i3 + 4*i9*i4 - 2*i9*i5 + 2*i9*i6 ...
    + 6*i9*i7 - 6*i9*i8 - 7*SQR(i9) ...
    - 6*i10*i3 ...
    - 2*i10*i4 - 4*i10*i5 - 4*i10*i9 ...
    - 8*SQR(i10) ...
    + 2*i10*i8 + 1430;
  g(6) =2*i2*i1 - 7*SQR(i1) - 7*SQR(i2) - 6*i3*i1 ...
    - 2*i3*i2 - 6*SQR(i3) - 2*i4*i1 + 2*i4*i2 ...
    - 2*i4*i3 - 5*SQR(i4) - 2*i5*i1 - 4*i5*i3 ...
    + 2*i5*i4 - 5*SQR(i5) + 2*i6*i1 - 4*i6*i2 ...
    + 4*i6*i3 + 2*i6*i4 + 6*i6*i5 - 9*SQR(i6) ...
    + 4*i7*i2 - 4*i7*i3 + 4*i7*i4 - 4*i7*i5 ...
    + 8*i7*i6 - 6*SQR(i7) + 4*i8*i1 + 8*i8*i2 ...
    + 2*i8*i3 - 4*i8*i4 - 2*i8*i5 + 4*i8*i6  ...
    - 9*SQR(i8) - 4*i9*i1 + 2*i9*i4 + 6*i9*i5 ...
    - 4*i9*i6 - 2*i9*i7 + 2*i9*i8 - 6*SQR(i9) ...
    + 2*i10*i1 - 2*i10*i5 - 4*i10*i6 ...
    + 2*i10*i7 ...
    + 2*i10*i8 + 6*i10*i9 - 5*SQR(i10) + 1020;
  g(7) = (-9*SQR(i1)) - 4*i2*i1 - 8*SQR(i2) ...
    + 4*i3*i1 ...
    + 2*i3*i2 - 7*SQR(i3) + 4*i4*i1 + 4*i4*i3 ...
    - 7*SQR(i4) - 2*i5*i1 - 12*i5*i2 ...
    - 4*i5*i3 ...
    - 8*SQR(i5) - 8*i6*i1 + 2*i6*i2 - 2*i6*i5 ...
    - 6*SQR(i6) - 4*i7*i1 - 6*i7*i2 - 2*i7*i3 ...
    + 10*i7*i4 - 2*i7*i5 + 2*i7*i6 ...
    - 7*SQR(i7) ...
    - 2*i8*i1 + 2*i8*i2 + 2*i8*i3 + 2*i8*i4 ...
    - 6*i8*i6 - 2*i8*i7 - 6*SQR(i8) + 4*i9*i1 ...
    + 2*i9*i2 + 4*i9*i3 + 4*i9*i4 + 2*i9*i5 ...
    - 2*i9*i6 - 9*SQR(i9) + 6*i10*i1 ...
    - 6*i10*i3 ...
    + 10*i10*i4 + 6*i10*i6 - 8*i10*i7 ...
    - 4*i10*i9 - 8*SQR(i10) + 2860;
  g(8) =  4*i2*i1 - 7*SQR(i1) - 8*SQR(i2) ...
    + 4*i3*i1 ...
    - 8*SQR(i3) + 4*i4*i1 + 8*i4*i2 - 6*i4*i3 ...
    - 7*SQR(i4) - 2*i5*i2 + 2*i5*i4 ...
    - 5*SQR(i5) ...
    - 2*i6*i1 - 2*i6*i2 + 4*i6*i4 - 4*i6*i5 ...
    - 7*SQR(i6) - 2*i7*i1 + 8*i7*i2 - 2*i7*i3 ...
    - 2*i7*i4 + 6*i7*i5 + 2*i7*i6 - 7*SQR(i7) ...
    + 2*i8*i1 - 6*i8*i2 + 6*i8*i3 + 4*i8*i4...
    + 2*i8*i5 - 4*i8*i6 - 6*SQR(i8) + 4*i9*i1 ...
    - 6*i9*i2 + 2*i9*i3 - 2*i9*i4 + 2*i9*i5 ...
    + 6*i9*i6 + 2*i9*i7 - 4*i9*i8 - 6*SQR(i9) ...
    - 2*i10*i1 - 2*i10*i2 - 4*i10*i3 ...
    + 4*i10*i5 ...
    + 4*i10*i6 + 2*i10*i8 - 4*i10*i9 ...
    - 6*SQR(i10)...
    + 880;
  g(9) =2*i2*i1 - 4*SQR(i1) - 7*SQR(i2) + 8*i3*i1 ...
    - 4*i3*i2 - 9*SQR(i3) - 2*i4*i1 - 4*i4*i2 ...
    - 2*i4*i3 - 6*SQR(i4) + 4*i5*i1 + 2*i5*i2 ...
    + 4*i5*i3 + 6*i5*i4 - 6*SQR(i5) + 4*i6*i3 ...
    - 6*i6*i4 - 7*SQR(i6) - 2*i7*i2 - 4*i7*i3 ...
    + 4*i7*i5 + 8*i7*i6 - 7*SQR(i7) + 2*i8*i2 ...
    - 4*i8*i3 + 2*i8*i4 + 2*i8*i5 + 6*i8*i7...
    - 7*SQR(i8) + 4*i9*i1 + 2*i9*i2 ...
    - 10*i9*i3 ...
    + 2*i9*i5 + 2*i9*i6 - 8*i9*i8 - 6*SQR(i9) ...
    + 2*i10*i1 + 2*i10*i2 + 4*i10*i3 ...
    + 8*i10*i4 ...
    - 4*i10*i5 - 2*i10*i6 + 2*i10*i7 ...
    - 2*i10*i8 ...
    + 2*i10*i9 - 8*SQR(i10) + 700;
  g(10) = 6*i2*i1 - 7*SQR(i1) - 6*SQR(i2) ...
    - 10*i3*i1 ...
    + 6*i3*i2 - 8*SQR(i3) + 4*i4*i1 + 2*i4*i2 ...
    + 2*i4*i3 - 8*SQR(i4) - 2*i5*i1 + 2*i5*i2 ...
    + 8*i5*i4 - 4*SQR(i5) + 4*i6*i1 + 2*i6*i3 ...
    - 4*i6*i4 + 2*i6*i5 - 2*SQR(i6) - 2*i7*i1 ...
    + 2*i7*i2 - 4*i7*i3 + 2*i7*i4 + 2*i7*i5 ...
    + 2*i7*i6 - 6*SQR(i7) - 2*i8*i1 + 2*i8*i2 ...
    - 6*i8*i3 + 6*i8*i4 - 2*i8*i5 + 2*i8*i6 ...
    - 4*i8*i7 - 5*SQR(i8) + 4*i9*i1 - 4*i9*i2 ...
    - 10*i9*i4 + 6*i9*i5 - 2*i9*i6 + 2*i9*i7 ...
    + 4*i9*i8 - 6*SQR(i9) + 2*i10*i2 ...
    - 4*i10*i3 ...
    + 2*i10*i4 - 2*i10*i5 + 2*i10*i6 ...
    + 4*i10*i7 ...
    - 6*i10*i8 + 2*i10*i9 - 7*SQR(i10) + 360;
  
end

function [y] = SQR(x)
y = x^2;
return
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%   END OF FILE   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
