%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%
%     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  = 35; % Number of variables (in total)
problem.ni = 14; % Number of integer variables (0 <= ni <= n)
problem.m  = 44; % Number of constraints (in total)
problem.me =  8; % 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   = 1 * 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  = 999999999;    % 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  = 50000;  % 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) =  14.37;  % 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) =  15;  % 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 )

%  Rename Integer Variables
   y(1)  = x(22);
   y(2)  = x(23);
   y(3)  = x(24);
   y(4)  = x(25);
   y(5)  = x(26);
   y(6)  = x(27);
   y(7)  = x(28);
   y(8)  = x(29);
   y(9)  = x(30);
   y(10) = x(31);
   y(11) = x(32);
   y(12) = x(33);
   y(13) = x(34);
   y(14) = x(35);

%  Objective function value F(X) (denoted here as 'f')
   f = 42.18*x(1)*x(1) + 40.36*x(1)*x(2) + 21.76*x(1)*x(3)... 
     + 10.60*x(1)*x(4) + 24.64*x(1)*x(5) + 47.68*x(1)*x(6)... 
     + 34.82*x(1)*x(7) + 70.89*x(2)*x(2) + 43.16*x(2)*x(3)... 
     + 30.82*x(2)*x(4) + 46.48*x(2)*x(5) + 47.60*x(2)*x(6)... 
     + 25.24*x(2)*x(7) + 25.51*x(3)*x(3) + 19.20*x(3)*x(4)... 
     + 45.26*x(3)*x(5) + 26.44*x(3)*x(6) +  9.40*x(3)*x(7)... 
     + 22.33*x(4)*x(4) + 20.64*x(4)*x(5) + 20.92*x(4)*x(6)... 
     +  2.00*x(4)*x(7) + 30.01*x(5)*x(5) + 32.72*x(5)*x(6)... 
     + 14.40*x(5)*x(7) + 42.23*x(6)*x(6) + 19.80*x(6)*x(7)... 
     + 16.42*x(7)*x(7) - 0.06435*x(1) - 0.0548*x(2)... 
     - 0.02505*x(3) - 0.0762*x(4) - 0.03815*x(5)... 
     - 0.0927*x(6) - 0.031*x(7);
           
%  Equality constraints G(X) = 0 MUST COME FIRST in 'g(1:me)'
   g(1) = x(1) + x(2) + x(3) + x(4) + x(5) + x(6) + x(7) - 1.0;
   g(2) = x(1) - x(8) + x(15) - 0.2;
   g(3) = x(2) - x(9) + x(16) - 0.2;
   g(4) = x(3) - x(10) + x(17); 
   g(5) = x(4) - x(11) + x(18); 
   g(6) = x(5) - x(12) + x(19) - 0.2;
   g(7) = x(6) - x(13) + x(20) - 0.2;
   g(8) = x(7) - x(14) + x(21) - 0.2;
   
%  Inequality constraints G(X) >= 0 MUST COME SECOND in 'g(me+1:m)'         
   g( 9) = x(8) + x(9) + x(10) + x(11) + x(12) + x(13) + x(14) - 0.3;
   g(10) = -(x(8) - 0.11*y(1));
   g(11) = -(x(9) - 0.1*y(2));
   g(12) = -(x(10) - 0.07*y(3));
   g(13) = -(x(11) - 0.11*y(4));
   g(14) = -(x(12) - 0.2*y(5));
   g(15) = -(x(13) - 0.1*y(6));
   g(16) = -(x(14) - 0.1*y(7));
   g(17) = x(8) - 0.03*y(1);
   g(18) = x(9) - 0.04*y(2);
   g(19) = x(10) - 0.04*y(3); 
   g(20) = x(11) - 0.03*y(4);
   g(21) = x(12) - 0.03*y(5);
   g(22) = x(13) - 0.03*y(6);
   g(23) = x(14) - 0.03*y(7);
   g(24) = -(x(15) - 0.2*y(8));
   g(25) = -(x(16) - 0.15*y(9));
   g(26) = -x(17);
   g(27) = -x(18);
   g(28) = -(x(19) - 0.1*y(12));
   g(29) = -(x(20) - 0.15*y(13));
   g(30) = -(x(21) - 0.2*y(14));
   g(31) = x(15) - 0.02*y(8);
   g(32) = x(16) - 0.02*y(9);
   g(33) = x(17) - 0.04*y(10);
   g(34) = x(18) - 0.04*y(11);
   g(35) = x(19) - 0.04*y(12);
   g(36) = x(20) - 0.04*y(13);
   g(37) = x(21) - 0.04*y(14);
   g(38) = -(y(1) + y(8)) + 1.0;
   g(39) = -(y(2) + y(9)) + 1.0;
   g(40) = -(y(3) + y(10)) + 1.0;
   g(41) = -(y(4) + y(11)) + 1.0;
   g(42) = -(y(5) + y(12)) + 1.0;
   g(43) = -(y(6) + y(13)) + 1.0;
   g(44) = -(y(7) + y(14)) + 1.0;  

end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%   END OF FILE   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
