Description Usage Arguments Value Note Author(s) References See Also Examples
To solve optimization problem using PSG solvers it is necessary to prepare problem in General (Text) format. There are three main objects of PSG:
Problem Statement.
It is a character with description of optimization problem.
This object must be created according to the rules of PSG General format.
Problem statement for optimization problems with one constraint:
(minimize|maximize)
[<coef1>*]<PSG function obj 1>
.........
[<coefK>*]<PSG function obj K>
Constraint:(<=|>=|==) <bound>
[<coef1>*]<PSG function constr 1>
.........
[<coefK>*]<PSG function constr K>
Box: (<=|>=|==) <bound>
PSG Data Objects. Data for optimization problem in a specific format: PSG Matrix, PSG PMatrix, PSG Point, and PSG Vector.
PSG Solution. The results of optimization problem are stored in solution report (character) and PSG Data Objects (PSG Matrix, PSG Point, ect).
1 2 | rpsg_solver(problem_list, rho = parent.frame(), allowExt = TRUE,
rpsg_suppress.Messages = FALSE)
|
problem_list |
list with data for optimization problem. List members:
|
rho |
optional parameter for setting frame. Default is rho = parent.frame(). |
allowExt |
optional parameter to specify if a solver can use variables from data frame defined in rho (by the default allowExt = TRUE) or not (allowExt = FALSE). |
rpsg_suppress.Messages |
optional parameter specifying if messages, that may appear when you run this function, should be suppressed (rpsg_suppress.Messages = TRUE) or not (by the default: rpsg_suppress.Messages = FALSE). |
list output.list
with solution results:
output.list$problem_name
name (problem_<name>) of the optimization problem. By default: problem_1;
output.list$solution_status
status of solution of the optimization problem: optimal | feasible | infeasible | unbounded | calculated (for calculation problems);
output.list$problem_statement
Problem Statement of the solved problem;
output.list$output
solution report = character with main information about optimization results;
output.list$point_constraints_problem_<name>
optimal values of left hand sides of constraints in optimization problem;
output.list$point_slack_constraints_problem_<name>
slacks value for constraints of the optimization problem;
output.list$point_dual_constraints_problem_<name>
dual constraints values;
output.list$point_problem_<name>
optimal point for solved optimization problem;
output.list$log
information about solving process.
rpsg_solver supports two cases of input data:
1. all PSG data objects are saved in input list,
2. all PSG data objects are saved in Global Environment.
In both cases input list must include PSG Problem Statement (problem_list$problem_statement)
and names of PSG data objects (names of list members or variables) should be used in Problem Statement.
Use rpsg_getsolution
to convert character solution report into list witn numeric data.
Use rpsg_verify
to verify problem before optimization.
List with solution results output.list may include output matrices, vectors and points not mentioned above. It is due to the specific of some PSG functions used in optimization problem.
Stan Uryasev [aut, cre, cph], Grigoriy Zrazhevsky [aut], Viktor Kuzmenko [aut], Alex Zrazhevsky [aut]
Maintainer: Stan Uryasev <stan.uryasev@aorda.com>
American Optimal Decisions
Portfolio Safeguard Help
rpsg_verify
rpsg_riskprog
rpsg_getsolution
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | #Problem of CVaR minimization with constraint on the mean profit:
#Find x = (x1,x2,x3,x4) minimizing
#risk(x) = CVaR(0.95,x)
#subject to
#Average Gain(x)>4.5
#x1+x2+x3+x4 = 1
#x1>=0, x2>=0, x3>=0, x4>=0
matrix_scenarios <- matrix(c(1,4,8,3, 7,5,4,6, 2,8,1,0,0,3,4,9),nrow=4, byrow=TRUE)
colnames(matrix_scenarios) <- colnames(matrix_scenarios,do.NULL = FALSE, prefix = "x")
scenario_benchmark <- c(0.2, 0.11, 0.6, 0.1)
matrix_scenarios <- cbind(matrix_scenarios,scenario_benchmark)
matrix_budget <- matrix(c(1, 1, 1, 1),nrow=1)
colnames(matrix_budget) <- colnames(matrix_budget,do.NULL = FALSE, prefix = "x")
point_lowerbounds <- c(0, 0, 0, 0)
names(point_lowerbounds) <- rownames(point_lowerbounds,do.NULL = FALSE, prefix = "x")
# Case 1. PSG data is saved in list
problem_list <- list()
#Problem Statement
problem_list$problem_statement <- sprintf(
"minimize
cvar_risk(0.95,matrix_scenarios)
Constraint: >= 4.5
avg_g(matrix_scenarios)
Constraint: == 1
linear(matrix_budget)
Box: >= point_lowerbounds
Solver:CAR")
# PSG Matrix:
problem_list$matrix_scenarios <- matrix_scenarios
# PSG Matrix:
problem_list$matrix_budget <- matrix_budget
# PSG Point:
problem_list$point_lowerbounds <- point_lowerbounds
# Solve optimization problem
output.list.1 <- rpsg_solver(problem_list)
print(output.list.1)
# Case 2. PSG data is saved in Global Environment
problem_list <- list()
#Problem Statement
problem_list$problem_statement <- sprintf(
"minimize
cvar_risk(0.95,matrix_scenarios)
Constraint: >= 4.5
avg_g(matrix_scenarios)
Constraint: == 1
linear(matrix_budget)
Box: >= point_lowerbounds")
output.list.2 <- rpsg_solver(problem_list)
print(output.list.2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.