/***********************************************************************/ /* // MIDACO 7 benchmark - MINLPLib pooling_haverly2tp: Surrogate mode // ------------------------------------------------------------------ // // The pooling problem of Haverly (case 2): two crude oils are blended in // a pool, the pool and a third crude are blended into two products with // limits on the sulfur content. The mixing of unknown flows with unknown // proportions gives bilinear equality constraints and several local // optima. Formulation with proportion variables (TP) of Alfaki and // Haugland. Shown here as an EXPENSIVE problem: with the SURROGATE mode // MIDACO reaches the optimum in a few hundred evaluations. // // References: C. A. Haverly, Studies of the behavior of recursion for // the pooling problem, ACM SIGMAP Bulletin 25 (1978) 19-28. // M. Alfaki and D. Haugland, Strong formulations for the pooling // problem, Journal of Global Optimization 56 (2013) 897-916. // MINLPLib instance pooling_haverly2tp: // https://www.minlplib.org/pooling_haverly2tp.html // // Variables: 10 continuous variables // Constraints: 13 (5 equality, 8 inequality) // Optimum: F(X) = -600 (proven optimal; MINLPLib maximizes the profit 600) // // MIDACO setting: PARAM(14) = 1 (SURROGATE, RBF model), constraint // accuracy 1e-4, budget of 10000 evaluations, start at the lower // bounds, the run stops when F(X) is within 0.01 % of the optimum // (FSTOP). With the default PARAM(14) = 0 the median run needs about // 1,000 evaluations, single runs up to 96,000 (seeds 0 to 7). // // Run it with: cargo run --release (Cargo.toml with name and path of pooling_haverly2tp_surrogate.rs) // // This benchmark needs a full MIDACO license: the limited version // solves problems with up to 8 variables and the default parameters. */ /***********************************************************************/ #![allow(non_snake_case)] mod midaco; /* The MIDACO gateway midaco.rs */ fn main() { let key = "************************************************************"; let o = 1; /* Number of objectives */ let n = 10; /* Number of variables (in total) */ let ni = 0; /* Number of integer variables (0 <= ni <= n) */ let m = 13; /* Number of constraints (in total) */ let me = 5; /* Number of equality constraints (0 <= me <= m) */ let xl = vec![ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; let xu = vec![ 1.0, 1.0, 600.0, 200.0, 600.0, 200.0, 800.0, 800.0, 600.0, 200.0 ]; let x = xl.clone(); /* Starting point: lower bounds */ let problem = midaco::Problem { o, n, ni, m, me, xl, xu, x }; let mut option = midaco::Options::default(); option.maxeval = 10000; option.maxtime = 60*60*24; option.printeval = 1; option.save2file = 1; option.resumable = 0; option.param[ 0] = 1e-4; /* ACCURACY */ option.param[ 1] = 0.0; /* SEED */ option.param[ 2] = -600.0 + 1e-4*600.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] = 1.0; /* SURROGATE */ option.param[14] = 0.0; /* PMISQP */ option.parallel = 0; /* Serial: 0 or 1, Parallel: 2,3,4,5,6,7,8... (threads) */ #[allow(unused_variables)] let solution = midaco::run( problem_function, &problem, &option, key ); } /***********************************************************************/ fn problem_function( f: &mut [f64], g: &mut [f64], x: &[f64] ) { /* MINLPLib model pooling_haverly2tp in scalar form: objective f, constraints g */ /* g[0..4] are equality constraints (= 0), g[5..12] inequality constraints (>= 0) */ f[0] = -3.0*x[2]-9.0*x[3]+7.0*x[4]+x[5]+x[8]-5.0*x[9]; g[0] = x[0]+x[1]-1.0; g[1] = -x[0]*x[6]+x[2]; g[2] = -x[1]*x[6]+x[3]; g[3] = -x[0]*x[7]+x[4]; g[4] = -x[1]*x[7]+x[5]; g[5] = 800.0-(x[2]+x[3]); g[6] = 800.0-(x[4]+x[5]); g[7] = 800.0-(x[8]+x[9]); g[8] = 800.0-(x[2]+x[3]+x[4]+x[5]); g[9] = 600.0-(x[2]+x[4]+x[8]); g[10] = 200.0-(x[3]+x[5]+x[9]); g[11] = -(0.5*x[2]-1.5*x[4]-0.5*x[8]); g[12] = -(1.5*x[3]-0.5*x[5]+0.5*x[9]); }