Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YAML file of portfolio selection example #31

Open
heshriti opened this issue Apr 9, 2019 · 2 comments
Open

YAML file of portfolio selection example #31

heshriti opened this issue Apr 9, 2019 · 2 comments
Assignees
Labels
help-wanted a user or developer needs help or guidance

Comments

@heshriti
Copy link

heshriti commented Apr 9, 2019

Hi,

do you have a YAML file of the portfolio selection problem in the cvx page?
(https://kul-forbes.github.io/scs/page_cvx_examples.html)

Thank you.

@alphaville alphaville self-assigned this Apr 11, 2019
@alphaville alphaville added the help-wanted a user or developer needs help or guidance label Apr 11, 2019
@alphaville
Copy link
Member

Hi @heshriti. You can download the YAML file you requested from this link.

If you would like to generate it yourself, you need to follow these steps:

  1. Run the portfolio selection example using the option dumpfile; this will create a MAT file with the problem data
  2. Run problem_to_yaml to export the problem in YAML format

Here is the code:

%% Run the portfolio selection problem
density = 0.1;
rc = 0.5; % estimated reciprocal condition number
n = 100000;
m = 100;
mu = exp(0.01 * randn(n, 1)) - 1; % returns
D = rand(n,1) / 10; % idiosyncratic risk
F = sprandn(n, m, density, rc) / 10; % factor model
gamma = 1;
B = 1;
cvx_begin
    cvx_solver scs
    cvx_solver_settings('eps', 1e-4,...
        'do_super_scs', 1,...
        'direction', 100,...
        'memory', 100, ...
        'dumpfile', 'portfolio.mat')
    variable x(n)
    maximize(mu'*x - gamma*(sum_square(F'*x) + sum_square(D.*x)))
    sum(x) == B
    x >= 0
cvx_end

%% Serialize the problem 
load('portfolio.mat');
problem_to_yaml('portfolio.yml', 'MyPortfolio', data, K);

@alphaville alphaville changed the title C YAML file of portfolio selection example Apr 11, 2019
@heshriti
Copy link
Author

@alphaville Thanks Pantellis.

Is it possible to share python or c example to generate this yaml? I don't have matlab unfortunately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help-wanted a user or developer needs help or guidance
Projects
None yet
Development

No branches or pull requests

2 participants