Notes - Tutorial for the Optimization Toolbox...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Tutorial for the Optimization Toolbox file:///C:/Program%20Files/MATLAB/R2007a%20Student/toolbox/opti. .. 1 of 11 8/21/2008 5:03 PM Run in the Command Window Tutorial for the Optimization Toolbox This is a demonstration for the medium-scale algorithms in the Optimization Toolbox. It closely follows the Tutorial section of the users' guide. All the principles outlined in this demonstration apply to the other nonlinear solvers: FGOALATTAIN, FMINIMAX, LSQNONLIN, FSOLVE. The routines differ from the Tutorial Section examples in the User's Guide only in that some objectives are anonymous functions instead of M-file functions. Contents Unconstrained Optimization Example Constrained Optimization Example: Inequalities Constrained Optimization Example: Inequalities and Bounds Constrained Optimization Example: User-Supplied Gradients Constrained Optimization Example: Equality Constraints Changing the Default Termination Tolerances Unconstrained Optimization Example Consider initially the problem of finding a minimum of the function: 2 2 f(x) = exp(x(1)) . (4x(1) + 2x(2) + 4x(1).x(2) + 2x(2) + 1) Define the objective to be minimized as an anonymous function: fun = @(x) exp(x(1)) * (4*x(1)^2 + 2*x(2)^2 + 4*x(1)*x(2) + 2*x(2) + 1) fun = @(x)exp(x(1))*(4*x(1)^2+2*x(2)^2+4*x(1)*x(2)+2*x(2)+1) Take a guess at the solution: x0 = [-1; 1]; Set optimization options: turn off the large-scale algorithms (the default): options = optimset( 'LargeScale' , 'off' ); Call the unconstrained minimization function: [x, fval, exitflag, output] = fminunc(fun, x0, options); Optimization terminated: relative infinity-norm of gradient less than options.TolFun. The optimizer has found a solution at: x Open tutdemo.m in the Editor
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
file:///C:/Program%20Files/MATLAB/R2007a%20Student/toolbox/opti. .. 2 of 11 8/21/2008 5:03 PM x = 0.5000 -1.0000 The function value at the solution is: fval fval = 3.6609e-015 The total number of function evaluations was: output.funcCount ans = 66 Constrained Optimization Example: Inequalities Consider the above problem with two additional constraints: 2 2 minimize f(x) = exp(x(1)) . (4x(1) + 2x(2) + 4x(1).x(2) + 2x(2) + 1) subject to 1.5 + x(1).x(2) - x(1) - x(2) <= 0 - x(1).x(2) <= 10 The objective function this time is contained in an M-file, objfun.m: type objfun function f = objfun(x) % Objective function % Copyright 1990-2004 The MathWorks, Inc. % $Revision: 1.1.6.1 $ $Date: 2006/11/11 22:48:52 $ f = exp(x(1)) * (4*x(1)^2 + 2*x(2)^2 + 4*x(1)*x(2) + 2*x(2) + 1); The constraints are also defined in an M-file, confun.m: type confun function [c, ceq] = confun(x) % Nonlinear inequality constraints: % Copyright 1990-2004 The MathWorks, Inc. % $Revision: 1.1.6.1 $
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/25/2010 for the course ESI 6314 taught by Professor Vladimirlboginski during the Fall '09 term at University of Florida.

Page1 / 11

Notes - Tutorial for the Optimization Toolbox...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online