%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%
%     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  = 24; % Number of variables (in total)
problem.ni = 24; % Number of integer variables (0 <= ni <= n)
problem.m  = 20; % 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   = 24 * 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  = 10000;  % 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) =  -29605;  % 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);
  i11 = x(11);
  i12 = x(12);
  i13 = x(13);
  i14 = x(14);
  i15 = x(15);
  i16 = x(16);
  i17 = x(17);
  i18 = x(18);
  i19 = x(19);
  i20 = x(20);
  i21 = x(21);
  i22 = x(22);
  i23 = x(23);
  i24 = x(24);
  
  f = 7*i1*i1 + 300*i1 + 4*i2*i2 + 270*i2 ...
  + 6*i3*i3 - 460*i3 + 8*i4*i4 + 800*i4 ...
  + 12*i5*i5 + 740*i5+ 9*i6*i6 - 600*i6 ...
  + 14*i7*i7 + 540*i7 + 7*i8*i8+ 380*i8 ...
  + 13*i9*i9 + 300*i9 + 12*i10*i10 - 490*i10 ...
  + 8*i11*i11 + 380*i11 + 4*i12*i12 ...
  + 760*i12 + 7*i13*i13 - 430*i13 + 9*i14*i14 ...
  + 250*i14 + 16*i15*i15 + 390*i15 ...
  + 8*i16*i16 + 600*i16 + 4*i17*i17 - 210*i17 ...
  + 10*i18*i18+ 830*i18 + 21*i19*i19 ...
  + 470*i19 + 13*i20*i20 - 680*i20+ 17*i21*i21 ...
  + 360*i21 + 9*i22*i22 + 290*i22 + 8*i23*i23 ...
  - 400*i23 + 4*i24*i24 + 310*i24;

  g(1) = - (- i1 - i5 - i9 - i13 - i17 - i21 + 29);
  g(2) = - (- i2 - i6 - i10 - i14 - i18 - i22 + 41);
  g(3) = - (- i3 - i7 - i11 - i15 - i19 - i23 + 13);
  g(4) = - (- i4 - i8 - i12 - i16 - i20 - i24 + 21);
  g(5) = - (- i1 - i2 - i3 - i4 + 8);
  g(6) = - (- i5 - i6 - i7 - i8 + 24);
  g(7) = - (- i9 - i10 - i11 - i12 + 20);
  g(8) = - (- i13 - i14 - i15 - i16 + 24);
  g(9) = - (- i17 - i18 - i19 - i20 + 16);
  g(10) = - (- i21 - i22 - i23 - i24 + 12);
  g(11) = - (i1 + i5 + i9 + i13 + i17 + i21 - 29);
  g(12) = - (i2 + i6 + i10 + i14 + i18 + i22 - 41);
  g(13) = - (i3 + i7 + i11 + i15 + i19 + i23 - 13);
  g(14) = - (i4 + i8 + i12 + i16 + i20 + i24 - 21);
  g(15) = - (i1 + i2 + i3 + i4 - 8);
  g(16) = - (i5 + i6 + i7 + i8 - 24);
  g(17) = - (i9 + i10 + i11 + i12 - 20);
  g(18) = - (i13 + i14 + i15 + i16 - 24);
  g(19) = - (i17 + i18 + i19 + i20 - 16);
  g(20) = - (i21 + i22 + i23 + i24 - 12);

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

