None.
None.
Open in the MATLAB editor: e04vg_example
function e04vg_example fprintf('e04vg example results\n\n'); start = int64(0); objadd = 0; objrow = int64(6); prob = ' '; iarow = int64([1;2;4;4;5;5;6;6]); iacol = int64([3;4;1;2;1;2;3;4]); nea = int64(8); a = [ -1; -1; -1; 1; 1; -1; 3; 2]; igrow = int64([1;1;2;2;3;3;6;6]); igcol = int64([1;2;1;2;1;2;3;4]); neg = int64(8); xlow = [-0.55; -0.55; 0; 0]; xupp = [ 0.55; 0.55; 1200; 1200]; x = [ 0; 0; 0; 0]; xnames = {' '}; xstate = zeros(4, 1, 'int64'); flow = [-894.8; -894.8; -1294.8; -0.55; -0.55; -1e25]; fupp = [-894.8; -894.8; -1294.8; 1e25; 1e25; 1e25]; f = [ 0; 0; 0; 0; 0; 0]; fnames = {' '}; fstate = zeros(6, 1, 'int64'); fmul = zeros(6, 1); ns = int64(0); [cw, iw, rw, ifail] = e04vg; [x, xstate, xmul, f, fstate, fmul, ns, ninf, sinf, ... cw, iw, rw, cuser, ifail] = ... e04vh(... start, objadd, objrow, prob, @usrfun, iarow, iacol, ... nea, a, igrow, igcol, neg, xlow, xupp, xnames, flow, fupp, ... fnames, x, xstate, f, fstate, fmul, ns, cw, iw, rw); % x, xstate, xmul, f, fstate, fmul, ns, ninf, sinf, ifail fprintf('Final objective value : %8.1f\n',f(objrow)); fprintf('Optimal values for x : '); fprintf(' %9.2f',x); fprintf('\n'); function [status, f, g, user] = ... usrfun(status, n, x, needf, nf, f, needg, leng, g, user) if (needf > 0) % The nonlinear components of f_i(x) need to be assigned, f(1) = 1000*sin(-x(1)-0.25) + 1000*sin(-x(2) -0.25); f(2) = 1000*sin(x(1)-0.25) + 1000*sin(x(1)-x(2) -0.25); f(3) = 1000*sin(x(2)-x(1)-0.25) + 1000*sin(x(2) -0.25); % n.b. in this example there is no need to assign for the wholly % linear components f_4(x) and f_5(x). f(6) = 1.0d-6*x(3)^3 + 2.0d-6*x(4)^3/3; end if (needg > 0) % The derivatives of the function f_i(x) need to be assigned. % G(k) should be set to partial derivative df_i(x)/dx_j where % i = IGFUN(k) and j = IGVAR(k), for k = 1 to LENG. g(1) = -1000*cos(-x(1)-0.25); g(2) = -1000*cos(-x(2)-0.25); g(3) = 1000*cos(x(1)-0.25) + 1000*cos(x(1)-x(2) -0.25); g(4) = -1000*cos(x(1)-x(2)-0.25); g(5) = -1000*cos(x(2)-x(1)-0.25); g(6) = 1000*cos(x(2)-x(1)-0.25) + 1000*cos(x(2) -0.25); g(7) = 3.0d-6*x(3)^2; g(8) = 2.0d-6*x(4)^2; end
e04vg example results Final objective value : 5126.5 Optimal values for x : 0.12 -0.40 679.95 1026.07