Main Content

Use Problem-Based Optimize Live Editor Task Effectively

How the Problem-Based Optimize Live Editor Task Works

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

  • Optimize creates MATLAB® code.

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

  • The section executes either automatically (when Autorun is selected, see Leave Autorun Selected in Define Problem Mode) or when you run the section by Ctrl + Enter or by clicking the blue bar to the left of the section.

  • To run an optimization, set up the problem in Define problem mode, then switch to Solve problem mode and run the section.

What Does Select task mode Do?

The Select task mode section appears at the bottom of the Live Editor task. The two modes are:

  • Define problemOptimize creates MATLAB code representing the problem, but does not include a call to solve. Therefore, in Define problem mode, the task does not solve the problem.

  • Solve problemOptimize includes a call to solve after the problem creation code. Therefore, when the task runs in Solve problem mode, MATLAB solves the problem.

    Note

    If the Autorun checkbox is cleared, switching the task to Solve problem mode does not run the task, and therefore does not solve the problem.

Leave Autorun Selected in Define Problem Mode

The Autorun checkbox appears at the top right section of the task, as pictured.

Autorun checkbox

To have the task operate most reliably, keep the Autorun checkbox selected while in Define problem mode. 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.

When the Autorun checkbox is cleared, the task can be in an internally inconsistent state. In this state, the task creates warning labels: Inconsistency notification.

When the Autorun checkbox is cleared, switching the task to Solve problem mode does not run the task, and therefore does not solve the problem. In Solve problem mode, to keep the task from solving the problem every time you change something, clear the Autorun checkbox. In this case, to solve a problem, run the task by pressing Ctrl + Enter or by clicking the blue bar to the left of the section.

See Also

Related Topics