Main Content

Use Problem-BasedOptimizeLive Editor Task Effectively

How the Problem-BasedOptimizeLive Editor Task Works

TheOptimizeLive Editor task looks in many ways like a Graphical User Interface for optimization. However, it runs differently than you might expect.

  • Optimizecreates MATLAB®code.

  • Optimizeruns the created code when the Live Editor executes the section containing the task.

  • The section executes either automatically (when自动运行is on, seeLeave Autorun On in Define Problem Mode)或当您运行的部分Ctrl + Enteror by clicking the blue bar to the left of the section.

  • To run an optimization, set up the problem inDefine problemmode, then switch toSolve problemmode and run the section.

What DoesSelect task modeDo?

TheSelect task modesection appears at the bottom of the Live Editor task. The two modes are:

  • Define problemOptimizecreates MATLAB code representing the problem, but does not include a call tosolve. Therefore, inDefine problemmode, the task does not solve the problem.

  • Solve problemOptimizeincludes a call tosolveafter the problem creation code. Therefore, when the task runs inSolve problemmode, MATLAB solves the problem.

    Note

    If自动运行is off, switching the task toSolve problemmode does not run the task, and therefore does not solve the problem.

Leave Autorun On in Define Problem Mode

At the top right section of the task you can find three buttons, as pictured.

Autorun button

To have the task operate most reliably, leave自动运行enabled (green) while inDefine problemmode. Doing so enables the following behavior:

  • The list of available solvers stays synchronized with the problem as you change it.

  • The list of available options stays synchronized with the problem.

With自动运行off, the task can be in an internally inconsistent state. In this state, the task creates warning labels:Inconsistency notification.

When自动运行is off, switching the task toSolve problemmode does not run the task, and therefore does not solve the problem. InSolve problemmode, to keep the task from solving the problem every time you change something, set自动运行to off. In this case, to solve a problem, run the task by pressingCtrl + Enteror by clicking the blue bar to the left of the section.

See Also

Related Topics