%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% This is an Example Call of MIDACO 4.0
% -------------------------------------
%
% MIDACO solves the general Mixed Integer Non-Linear Program (MINLP):
%
%
% Minimize F(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 in the function
% '[f,g] = problem_function(x)'. You can use this example as a template to
% run MIDACO on your own problem. In order to do so: Replace the objective
% function 'F' (and in case the constraints 'g') given below with your own
% problem functions. Then simply follow the instruction steps 1 to 3 given
% in this file.
%
% See the MIDACO Header and MIDACO User Guide for more information.
%
% Author(C): Dr. Martin Schlueter
% Information Initiative Center,
% Division of Large Scale Computing Systems,
% Hokkaido University, Japan.
%
% Email: info@midaco-solver.com
% URL: http://www.midaco-solver.com
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function m3
%clear all; clear mex; clc;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Specify MIDACO License-Key
key = 'MIDACO-SOLVER-CLOUD-SERVER-[-XEON-2.27GHz-2GB-Ram-10000Sec-]';
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Step 1: Problem definition %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Step 1.A : Define name of problem function (by function handle symbol '@')
problem.func = @problem_function; % Call is: [f,g] = problem_function(x)
% Step 1.B : Define problem dimensions
problem.n = 26; % Number of variables (in total)
problem.ni = 6; % Number of integer variables (0 <= nint <= n)
problem.m = 43; % Number of constraints (in total)
problem.me = 0; % Number of equality constraints (0 <= me <= m)
% Step 1.C : Define lower and upper bounds 'xl' and 'xu' for 'x'
problem.xl = -100 * ones(1,problem.n);
problem.xu = 100 * ones(1,problem.n);
% special bounds from GAMS
problem.xl(7) = 2;
problem.xu(7) = 5.4772;
problem.xl(8) = 3;
problem.xu(8) = 6.7081;
problem.xl(9) = 3.8;
problem.xu(9) = 7.5498;
problem.xl(10) = 10;
problem.xu(10) = 10.0001;
problem.xl(11) = 1.8258;
problem.xu(11) = 5;
problem.xl(12) = 2.2361;
problem.xu(12) = 5;
problem.xl(13) = 2.5166;
problem.xu(13) = 5;
problem.xl(13) = 5;
problem.xu(13) = 5.0001;
% binaries
problem.xl(21:26) = 0;
problem.xu(21:26) = 1;
% Step 1.D : Define 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 : Decide maximal runtime by evalution and time budget
option.maxeval = 10000000; % 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 : Choose printing options
option.printeval = 25000; % 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 (ONLY FOR ADVANCED USERS) %%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
option.param(1) = 0; % ACCURACY (default value is 0.001)
option.param(2) = 0; % RANDOM-SEED (e.g. 1, 2, 3,... 1000)
option.param(3) = 37.8; % FSTOP
option.param(4) = 0; % AUTOSTOP (e.g. 1, 5, 20, 100,... 500)
option.param(5) = 0; % ORACLE
option.param(6) = 0; % FOCUS (e.g. +/- 10, 500,... 100000)
option.param(7) = 0; % ANTS (e.g. 2, 10, 50, 100,... 500)
option.param(8) = 0; % KERNEL (e.g. 2, 5, 15, 30,... 100)
option.param(9) = 0; % CHARACTER
% Note: The default value for all parameters is 0.
% See the MIDACO User Manual for more details.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Call MIDACO solver %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[ solution ] = midaco( problem, option, key);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% End of Example %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [ f, g ] = problem_function( x )
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
y = x(21:26);
x8 = x(1);
x9 = x(2);
x10 = x(3);
x11 = x(4);
x12 = x(5);
x13 = x(6);
x14 = x(7);
x15 = x(8);
x16 = x(9);
x17 = x(10);
x18 = x(11);
x19 = x(12);
x20 = x(13);
x21 = x(14);
x22 = x(15);
x23 = x(16);
x24 = x(17);
x25 = x(18);
x26 = x(19);
x27 = x(20);
b1 = y(1);
b2 = y(2);
b3 = y(3);
b4 = y(4);
b5 = y(5);
b6 = y(6);
f = 6*x10 + 6*x11 + 6*x12 + 6*x13;
e2 = x22 - x23;
e3 = 0.5*x14 - x17 + x22;
e4 = 0.5*x14 - x22;
e5 = 0.5*x18 - x21 + x25;
e6 = 0.5*x18 - x25;
e7 = 0.5*x15 - x17 + x23;
e8 = 0.5*x15 - x23;
e9 = 0.5*x19 - x21 + x26;
e10 = 0.5*x19 - x26;
e11 = 0.5*x16 - x17 + x24;
e12 = 0.5*x16 - x24;
e13 = 0.5*x20 - x21 + x27;
e14 = 0.5*x20 - x27;
e15 = -x8 + x22 - x23;
e16 = -x8 - x22 + x23;
e17 = -x9 + x25 - x26;
e18 = -x9 - x25 + x26;
e19 = -10*b1 - 10*b2 + 0.5*x14 + 0.5*x15 - x22 + x23;
e20 = -10*b1 + 10*b2 + 0.5*x14 + 0.5*x15 + x22 - x23 - 10;
e21 = 5*b1 - 5*b2 + 0.5*x18 + 0.5*x19 - x25 + x26 - 5;
e22 = 5*b1 + 5*b2 + 0.5*x18 + 0.5*x19 + x25 - x26 - 10;
e23 = -x10 + x22 - x24;
e24 = -x10 - x22 + x24;
e25 = -x11 + x25 - x27;
e26 = -x11 - x25 + x27;
e27 = -10*b3 - 10*b4 + 0.5*x14 + 0.5*x16 - x22 + x24;
e28 = -10*b3 + 10*b4 + 0.5*x14 + 0.5*x16 + x22 - x24 - 10;
e29 = 5*b3 - 5*b4 + 0.5*x18 + 0.5*x20 - x25 + x27 - 5;
e30 = 5*b3 + 5*b4 + 0.5*x18 + 0.5*x20 + x25 - x27 - 10;
e31 = -x12 + x23 - x24;
e32 = -x12 - x23 + x24;
e33 = -x13 + x26 - x27;
e34 = -x13 - x26 + x27;
e35 = -10*b5 - 10*b6 + 0.5*x15 + 0.5*x16 - x23 + x24;
e36 = -10*b5 + 10*b6 + 0.5*x15 + 0.5*x16 + x23 - x24 - 10;
e37 = 5*b5 - 5*b6 + 0.5*x19 + 0.5*x20 - x26 + x27 - 5;
e38 = 5*b5 + 5*b6 + 0.5*x19 + 0.5*x20 + x26 - x27 - 10;
e39 = 10/x14 - x18;
e40 = 10/x18 - x14;
e41 = 15/x15 - x19;
e42 = 15/x19 - x15;
e43 = 19/x16 - x20;
e44 = 19/x20 - x16;
g(1) = -e2;
g(2) = -e3;
g(3) = -e4;
g(4) = -e5;
g(5) = -e6;
g(6) = -e7;
g(7) = -e8;
g(8) = -e9;
g(9) = -e10;
g(10) = -e11;
g(11) = -e12;
g(12) = -e13;
g(13) = -e14;
g(14) = -e15;
g(15) = -e16;
g(16) = -e17;
g(17) = -e18;
g(18) = -e19;
g(19) = -e20;
g(20) = -e21;
g(21) = -e22;
g(22) = -e23;
g(23) = -e24;
g(24) = -e25;
g(25) = -e26;
g(26) = -e27;
g(27) = -e28;
g(28) = -e29;
g(29) = -e30;
g(30) = -e31;
g(31) = -e32;
g(32) = -e33;
g(33) = -e34;
g(34) = -e35;
g(35) = -e36;
g(36) = -e37;
g(37) = -e38;
g(38) = -e39;
g(39) = -e40;
g(40) = -e41;
g(41) = -e42;
g(42) = -e43;
g(43) = -e44;
return
%%%%%%%%%%%%%%%%%%
% End of File %
%%%%%%%%%%%%%%%%%%