Print Level = 1is an example of a string used to set an optional parameter. For each option the string contains one or more of the following items:
– | a mandatory keyword; |
– | a phrase that qualifies the keyword; |
– | a number that specifies an integer or double value. Such numbers may be up to contiguous characters in Fortran's I, F, E or D formats, terminated by a space if this is not the last item on the line. |
[lwsav, iwsav, rwsav, inform] = e04ue('Nolist', lwsav, iwsav, rwsav);suppresses printing of this and subsequent options. Printing will automatically be turned on again after a call to nag_opt_nlp1_solve (e04uc) and may be turned on again at any time using the keyword List.
None.
Open in the MATLAB editor: e04ue_example
function e04ue_example fprintf('e04ue example results\n\n'); n = 4; n_l = 1; n_n = 2; a = [1, 1, 1, 1]; bl = [1; 1; 1; 1; -10e+24; -10e+24; 25]; bu = [5; 5; 5; 5; 20; 40; 10e+24]; istate = zeros(7, 1, 'int64'); cjac = zeros(2, 4); clamda = zeros(7, 1); r = zeros(4, 4); %Initialize and set option [cwsav,lwsav,iwsav,rwsav,ifail] = e04wb('e04uc'); [lwsav, iwsav, rwsav, inform] = e04ue(... 'Verify Level = 0', lwsav, iwsav, rwsav); x = [1; 5; 5; 1]; %Solve [iter, istate, c, cjac, clamda, objf, objgrd, r, x] = ... e04uc(... a, bl, bu, @confun, @objfun, istate, cjac, ... clamda, r, x, lwsav, iwsav, rwsav); fprintf('Minimum value : %9.4f\n\n',objf); fprintf('Found after %3d iterations at x:\n ',iter); fprintf(' %9.4f',x); fprintf('\nObjective gradients:\n '); fprintf(' %9.4f',objgrd); fprintf('\nNonlinear contraint values c(x):\n '); fprintf(' %9.4f',c); fprintf('\n'); function [mode, c, cjac, user] = ... confun(mode, ncnln, n, ldcj, needc, x, cjac, nstate, user) c = zeros(ncnln, 1); if (nstate == 1) % first call to confun. set all jacobian elements to zero. % note that this will only work when 'derivative level = 3' % (the default; see section 11.2). cjac=zeros(ldcj, n); end if (needc(1) > 0) if (mode == 0 || mode == 2) c(1) = x(1)^2 + x(2)^2 + x(3)^2 + x(4)^2; end if (mode == 1 || mode == 2) cjac(1,1) = 2*x(1); cjac(1,2) = 2*x(2); cjac(1,3) = 2*x(3); cjac(1,4) = 2*x(4); end end if (needc(2) > 0) if (mode == 0 || mode == 2) c(2) = x(1)*x(2)*x(3)*x(4); end if (mode == 1 || mode == 2) cjac(2,1) = x(2)*x(3)*x(4); cjac(2,2) = x(1)*x(3)*x(4); cjac(2,3) = x(1)*x(2)*x(4); cjac(2,4) = x(1)*x(2)*x(3); end end function [mode, objf, objgrd, user] = objfun(mode, n, x, objgrd, nstate, user) if (mode == 0 || mode == 2) objf = x(1)*x(4)*(x(1)+x(2)+x(3)) + x(3); else objf = 0; end if (mode == 1 || mode == 2) objgrd(1) = x(4)*(2*x(1)+x(2)+x(3)); objgrd(2) = x(1)*x(4); objgrd(3) = x(1)*x(4) + 1; objgrd(4) = x(1)*(x(1)+x(2)+x(3)); end
e04ue example results Minimum value : 17.0140 Found after 5 iterations at x: 1.0000 4.7430 3.8211 1.3794 Objective gradients: 14.5723 1.3794 2.3794 9.5641 Nonlinear contraint values c(x): 40.0000 25.0000