Lesson 1. Create Problem using GUI

This lesson shows how to create and solve optimization problem in PSG MATLAB Toolbox.

 

Step 1. Open Toolbox
Step 2. Prepare Problem Statement in General (text) Format
Step 3. Prepare Data in PSG format
Step 4. Verify Problem
Step 5. Solve Problem
Step 6. Get solution outputs for the optimization problem
Step 7. Save optimization problem
Step 8. Continue reading Lesson 2

 

Step 1. Open Toolbox

 

Type in the MATLAB Command window the following command:

 

>> tbpsg_toolbox

 

The following screen will be opened:

 

Clear

 

Step 2. Prepare Problem Statement in General (text) Format

 

Problem statement syntax is described in Problem Statement in MATLAB.

For example, let us consider CVaR minimization problem:

 

The following problem statement should be typed in the Problem Statement window:

 

minimize

 cvar_risk(0.95, matrix_scenarios)

 

 

Clear_1

 

 

Step 3. Prepare Data in PSG format

 

To solve optimization problem in PSG Toolbox we need to define data for CVaR function (see cvar_risk PSG function). There are 5 types of PSG Data (see PSG Data Objects in MATLAB).  CVaR function is defined only by PSG Matrix.

To create a new PSG Matrix in Toolbox do the following steps:

1. In Command Window create MATLAB variable with data:

 

>> data1 = [1,2,3;4,5,6];

 

2. Press " Matrix Add" button in PSG Toolbox and  "psg_matrix" window will be opened.

 

Matrix_2

 

Matrix_3

 

 

3. Choose  MATLAB variable data1 to specify data for PSG Matrix and press OK.

 

Matrix_data

 

 

The created PSG Matrix is displayed in the window bottom. Note, that optimization problem variables are names of the columns; they are created automatically. You can change names of variables, if needed, by choosing in Variables line (in the psg_matrix window) a corresponding  MATLAB variable containing new names.

 

Matrix_data_1

 

 

4. Type name of the PSG Matrix ("scenarios" in this example). This name will be combined with the prefix "matrix_" and  displayed

in the Objects List Window. This matrix name is the argument in cvar_risk function: cvar_risk(0.95, matrix_scenarios).

 

Matrix_data_scenarios

 

 

5. Close Matrix window by pressing button "Ok". Created Matrix will be automatically saved.

 

Step 4. Verify Problem

 

Press button "Verify" to make sure that the problem is correctly formulated, i.e., no syntax errors or missed data in Problem Statement.

 

Matrix_verify

 

 

 

 

Step 5. Solve Problem

 

Press button "Solve" to start solving the optimization problem. Status of the optimization process is displayed in a separate widow. The solution process can be terminated any time by pressing "Terminate" button.

 

Matrix_solve

 

Matrix_verify_1

 

 

Step 6. Get solution outputs for the optimization problem

 

Solution of the optimization problem includes two parts (see PSG Solution in MATLAB):

Text Report = status of the solution, timing, values of objective, constraints, and functions.

Optimal Point = point containing optimal values of decision variables.

 

Open Solution  in the menu bar to view the solution outputs.

 

Solution

 

 

Step 7. Save optimization problem

 

Save problem with the results (if problem was solved) to MAT file using Menu: Data -> Save to MAT.

 

Data

 

 

Step 8. Continue reading Lesson 2