/***********************************************************************/ /* This is an example call of MIDACO 7 ----------------------------------- 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. Run it with: cargo run --release */ /***********************************************************************/ #![allow(non_snake_case)] /* the program is called example_NLPc */ mod midaco; /* The MIDACO gateway midaco.rs */ /***********************************************************************/ /************************ MAIN PROGRAM *****************************/ /***********************************************************************/ fn main() { let key = "MIDACO_LIMITED_VERSION___________________ALL_RIGHTS_RESERVED"; /*****************************************************************/ /*** Step 1: Problem definition ********************************/ /*****************************************************************/ /* STEP 1.A: Problem dimensions ******************************/ let o = 1; /* Number of objectives */ let n = 4; /* Number of variables (in total) */ let ni = 0; /* Number of integer variables (0 <= ni <= n) */ let m = 3; /* Number of constraints (in total) */ let me = 1; /* Number of equality constraints (0 <= me <= m) */ /* STEP 1.B: Lower and upper bounds 'xl' & 'xu' **********************************************/ let xl = vec![1.0; n]; let xu = vec![4.0; n]; /* STEP 1.C: Starting point 'x' ******************************/ let x = xl.clone(); /* Here for example: starting point = lower bounds */ let problem = midaco::Problem { o, n, ni, m, me, xl, xu, x }; /*****************************************************************/ /*** Step 2: Choose stopping criteria and printing options ****/ /*****************************************************************/ let mut option = midaco::Options::default(); /* STEP 2.A: Stopping criteria *****************************/ option.maxeval = 10000; /* Maximum evaluation budget (e.g. 1000000) */ option.maxtime = 60*60*24; /* Maximum time limit (e.g. 60*60*24 = 1 Day) */ /* STEP 2.B: Printing options ****************************/ option.printeval = 1000; /* Print-Frequency for current best solution (e.g. 1000) */ option.save2file = 1; /* Save SCREEN and SOLUTION to TXT-files [0=NO/1=YES] */ option.resumable = 0; /* Resumable mode [0=NO/1=YES] */ /*****************************************************************/ /*** Step 3: Choose MIDACO parameters (FOR ADVANCED USERS) ***/ /*****************************************************************/ option.param[ 0] = 0.0; /* ACCURACY */ option.param[ 1] = 0.0; /* SEED */ option.param[ 2] = 0.0; /* FSTOP */ option.param[ 3] = 0.0; /* ALGOSTOP */ option.param[ 4] = 0.0; /* EVALSTOP */ option.param[ 5] = 0.0; /* FOCUS */ option.param[ 6] = 0.0; /* ANTS */ option.param[ 7] = 0.0; /* KERNEL */ option.param[ 8] = 0.0; /* ORACLE */ option.param[ 9] = 0.0; /* PARETOMAX */ option.param[10] = 0.0; /* EPSILON */ option.param[11] = 0.0; /* BALANCE */ option.param[12] = 0.0; /* CHARACTER */ option.param[13] = 0.0; /* SURROGATE */ option.param[14] = 0.0; /* PMISQP */ /*****************************************************************/ /*** Step 4: Choose Parallelization Factor *********************/ /*****************************************************************/ option.parallel = 0; /* Serial: 0 or 1, Parallel: 2,3,4,5,6,7,8... (threads) */ /*****************************************************************/ /*********************** Run MIDACO ****************************/ /*****************************************************************/ #[allow(unused_variables)] let solution = midaco::run( problem_function, &problem, &option, key ); /* println!(" Solution f[0] = {}", solution.f[0]); */ /* println!(" Solution g[0] = {}", solution.g[0]); */ /* println!(" Solution x[0] = {}", solution.x[0]); */ } /***********************************************************************/ /*************************** END OF MAIN *****************************/ /***********************************************************************/ /***********************************************************************/ /********************* OPTIMIZATION PROBLEM ************************/ /***********************************************************************/ fn problem_function( f: &mut [f64], g: &mut [f64], x: &[f64] ) { /* Objective functions F(X) */ f[0] = (x[0]-1.0)*(x[0]-1.0) + (x[1]-2.0)*(x[1]-2.0) + (x[2]-3.0)*(x[2]-3.0) + (x[3]-4.0)*(x[3]-4.0) + 1.23456789; /* Equality constraints G(X) = 0 MUST COME FIRST in g[0..me] */ g[0] = x[0] - 1.0; /* Inequality constraints G(X) >= 0 MUST COME SECOND in g[me..m] */ g[1] = x[1] - 1.333333333; g[2] = x[2] - 2.666666666; } /***********************************************************************/ /*************************** END OF FILE *****************************/ /***********************************************************************/