How to Use the Problem-Based Optimize Live Editor Task - MATLAB
Video Player is loading.
Current Time 0:00
Duration 3:04
Loaded: 5.37%
Stream Type LIVE
Remaining Time 3:04
 
1x
  • Chapters
  • descriptions off, selected
  • en (Main), selected
    Video length is 3:04

    How to Use the Problem-Based Optimize Live Editor Task

    Interactively create and solve optimization problems with MATLAB®, Optimization Toolbox™, or Global Optimization Toolbox using a visual interface. The Optimize task guides you through the problem-based approach for specifying the type of problem by defining optimization variables, objective expressions, and constraint expressions.

    The visual interface provides an intuitive way to set up and solve optimization problems, especially for those who do not know the MATLAB coding syntax to do so. In addition, based on the problem you define, the Optimize task automatically chooses an appropriate solver. You can easily formulate and solve constrained and unconstrained nonlinear programs, linear programs, quadratic programs, second-order cone programs, mixed-integer programs, linear and nonlinear least squares problems, and systems of nonlinear equations.

    The example in the video shows how to minimize the cost of materials for a cylindrical soup can, subject to a set of linear, nonlinear, and bound constraints. While this example is conceptually simple, you apply the same approach to much more complex optimization problems.

    You start by defining the optimization variables, commonly referred to as design or decision variables, as symbolic variables. You then define objectives and constraints as expressions of these optimization variables. You can specify each objective and constraint using an existing function from a file, a function local to the Live Script, or by specifying the expression on one line.

    You can optionally specify some problem-dependent solver options, such as choosing a specific algorithm and modifying algorithm settings. You can choose which results to display.

    Once this is done, you run the task to solve the problem and view the results. Use the generated MATLAB code to reproduce these results in applications or to share with others.

    The Optimize Live Editor task makes it easier to solve your optimization problems by guiding you through the specification of the problem, adapting as you make selections, generating MATLAB code, and providing tool tips.

    Published: 20 Dec 2021

    Use the Optimize Live Editor task to solve a problem with the problem based optimization approach. The Optimize Task enables you to set up and run a problem based optimization interactively within a live script. It guides the process of creating optimization variables, defining the problem, and exploring options. As with all Live Editor tasks, you can reuse the generated code in applications, or save the Live Script with your selections to modify later or share with others.

    This example optimizes the height, h, and radius, r, of a cylindrical soup can. The goal is to minimize the cost of materials for the can, assumed to be directly proportional to its surface area. However, there are certain constraints for the design. The volume of the can must hold 300 milliliters of soup. For stability and stocking purposes, the can should be no taller than 15 centimeters, and the height should be no more than 4 times the radius. Lastly, only positive values of height and radius make physical sense. So height and radius must be greater than 0.

    In a new Live Script, you can insert the Optimize Live Editor task and select the problem based approach. With the problem based approach, you can write objectives and constraints as mathematical expressions of optimization variables, making it easier to define the problem. Start by defining the optimization variables, commonly referred to as design or decision variables. These are the variables the Solver will tune when solving the problem. Be sure to specify reasonable starting values for each.

    Next, define the problem. The goal is to minimize the surface area of can. You can specify the objective using an existing function from a file, a function local to the Live Script, or by specifying the objective on one line, which is seen here. Then add the constraints which limit the solution space. The Solver will aim to satisfy the constraints as the optimization variables are evaluated.

    Finally, select which results you want displayed. Review the problem summary in the output window, and click Solve Problem when you're ready to solve. The output window displays the optimized solution values of height and radius, as well as the minimized surface area objective value. Note that you can tune Solver options, and different Solvers can have different results. For this problem, the Solver takes longer and converges to a less optimal point than as means cone.

    As with all Live Tasks, you can easily access the code that represents all the work you did in the editor, which can be used in applications or shared with others. Use the Optimize Live Editor task for an interactive experience to set up and run an optimization problem, modify options, view results, and auto generate code. For more information, access the documentation through the Live Editor task.

    View more related videos