Integrated Component Optimization

This tutorial explains how to solve an optimization problem using a third-party tool to evaluate the objective function. It is a general example of integrating an external solver into a pSeven optimization workflow.


This tutorial requires the workflow from Workflow as a Block. It is also recommended to complete the Optimization Basics and Multi-Objective Optimization Basics tutorials first.

Before You Begin

This tutorial requires an existing prjTutorials project. If you have not created this project yet, see Tutorial Project first.

  • Open the prjTutorials project.
  • Open wfToySolverBlock (ToySolverBlock.p7wf).
  • Select File ‣ Save Workflow As... to create a copy of the workflow. Save the workflow as wfOptimizationIntegrated.
  • Verify that you are editing wfOptimizationIntegrated and continue with the tutorial.


Real optimization tasks rarely allow to define problem functions (objectives and constraints) in an analytical form, like it was done in the Optimization Basics and Multi-Objective Optimization Basics tutorials. In most cases the optimized model is evaluated by some external program (various simulation and modeling software). Therefore optimization in pSeven usually requires implementing a wrapper first — a workflow that integrates one or more external tools, creating a pSeven interface to this toolchain. This tutorial uses the Toy Solver integration workflow discussed in Integration Basics and Conditions and Error Handling. The corresponding block already exists in the current workflow (it was added in the Workflow as a Block tutorial). The task now is to configure an Optimizer block that will use the Toy Solver block to evaluate the problem functions.


Since model input and output properties are already known from the Workflow as a Block tutorial, the solution requires only to define the problem in Optimizer correctly, so that it can be connected to the model.

Problem Definition

Problem definition is similar to the Multi-Objective Optimization Basics tutorial except that vectors are used instead of scalar variables and objectives.

  • Add an Optimizer block. Name it Optimizer.

Add a vector variable.

  • Specify the name: x.
  • Select the vector type and set vector size, 2.
  • Specify bounds, 0 and 1. These bounds are applied to both components.
  • Leave other settings default and click b_ok.

Add a vector objective.

  • Specify the name: f.
  • Select the vector type and set vector size, 2.
  • Leave other settings default and click b_ok.


After adding a vector variable (objective, constraint), you can expand it in Optimizer configuration to show all components (see below). It allows to configure the components individually, for example specifying different bounds and initial guess values for each. This tutorial skips it for simplicity.

Verify the Optimizer configuration.


Also verify that the “Analytical problem” option preset is selected. Leave other block settings default and click b_ok in the configuration dialog.

Finally, create links connecting Optimizer to Model.

  • Link Optimizer.x to Model.x.
  • Link Model.f to Optimizer.f.

Note that the value assigned to Model.x is no longer used because this port is now a link target (there is no need to remove the port value).


Final workflow looks the same as a simple optimization task — additional complexity is hidden in the Model block.


Optimizer ports are monitored by default, so no additional configuration is required.


Analyzing results of a multi-objective optimization workflow is described in detail in the Multi-Objective Optimization Basics tutorial (see section Results).


For example, you can plot the components of the Optimizer.optimal_f record in the project database to visualize the Pareto frontier analyze evaluation history, and so on.