This lesson shows how to create and solve optimization problem in PSG MATLAB Toolbox.
Type in the MATLAB Command window the following command:
>> tbpsg_toolbox
The following screen will be opened:
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)
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.
3. Choose MATLAB variable data1 to specify data for PSG Matrix and press OK.
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.
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).
5. Close Matrix window by pressing button "Ok". Created Matrix will be automatically saved.
Press button "Verify" to make sure that the problem is correctly formulated, i.e., no syntax errors or missed data in Problem Statement.
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.
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.
Step 7. Save optimization problem
Save problem with the results (if problem was solved) to MAT file using Menu: Data -> Save to MAT.
Step 8. Continue reading Lesson 2