Lecture plan

Parallel computing basics

Optimization

? Optimization toolbox => Tutorials => Solver based:
 
Choose an optimization solver.
Create an objective function, typically the function you want to minimize.
Create constraints, if any.
Set options, or use the default options.
Call the appropriate solver.
For a basic nonlinear optimization example, see Solve a Constrained Nonlinear Problem.

Obj function

rosenbrock=@(x)100*(x(:,2) - x(:,1).^2).^2 + (1 - x(:,1)).^2;

Constraints: c(x) <= 0 or ceq(x)=0.

This example includes only an inequality constraint, so you must pass an empty array [] as the equality constraint function ceq.

function [c,ceq] = unitdisk(x)
c = x(1)^2 + x(2)^2 - 1;
ceq = [ ];

Run the optimization

  1. Optimiz app (not for us)
  2. Comand line (yes)

Minimize Rosenbrock's Function at the Command Line

  1. Create options that choose iterative display and the interior-point algorithm
         options = optimoptions(@fmincon,...
        'Display','iter','Algorithm','interior-point');
        
  2. Run the fmincon solver with the options structure, reporting both the location x of the minimizer and the value fval attained by the objective function.
        [x,fval] = fmincon(rosenbrock,[0 0],...
        [],[],[],[],[],[],@unitdisk,options)
        
    The six sets of empty brackets represent optional constraints that are not being used in this example. See the fmincon function reference pages for the syntax.

    MATLAB outputs a table of iterations and the results of the optimization.
    Local minimum found that satisfies the constraints.
    Optimization completed because the objective function is non-decreasing in feasible directions, to within the selected value of the function tolerance, and constraints are satisfied to within the selected value of the constraint tolerance.

    x =
        0.7864    0.6177
    fval =
        0.0457
    
OLD HP https://se.mathworks.com/help/optim/examples/using-symbolic-mathematics-with-optimization-toolbox-solvers.html

https://www.google.com/search?q=optimization+using+symbolic+derivatives&client=ubuntu&tbm=isch&tbs=rimg:CeXZXxMlo1fAIjjyRqNS7Ap5mXum17ibTaIpNmwA7OfaQ2OVEPv65Jbxda9CqlbA8CHPwEJ_1kqYecaj8U0gvps2mhSoSCfJGo1LsCnmZESdhRi5jEqgVKhIJe6bXuJtNoikR1BJ_1ZeCdqU4qEgk2bADs59pDYxFBKWZ3vMXpHioSCZUQ-_1rklvF1ESi010CXAlA5KhIJr0KqVsDwIc8RGMdMxwIWAg4qEgnAQn-Sph5xqBGtOnKwVxmZRCoSCfxTSC-mzaaFEV95esNLbWdk&tbo=u&sa=X&ved=2ahUKEwjwu-CHqLvhAhUCp4sKHTT5Ag8Q9C96BAgBEBs&biw=1700&bih=1010&dpr=1.09