Giter Site home page Giter Site logo

Comments (4)

echu avatar echu commented on June 28, 2024 1

Travis,

Do you happen to know what the optimal objective value is? I've increased
the maxiters for cvxopt and it seems to solve it, but I'm not sure if it's
accurate.

Eric

On Tue, Nov 5, 2013 at 1:23 AM, Travis Erdman [email protected]:

The code below (feel free to use it as a test case or example problem)
calculates the maximum expected log return for investment in 10 different
assets with 10 different outcome scenarios. The objective is similar to
that of acent.py, but it is a weighted sum of logs. The solvers do not
converge to the solution within maxiter, though it is a rather
straightforward problem. Any ideas?

import cvxpy as cvx
import cvxopt

scenario_probabilities = cvx.numpy.array((0.3,0.15,0.1,0.1,0.06,0.06,0.06,0.06,0.06,0.05)).reshape(1,-1)
joint_returns = cvx.numpy.array(
[[ 1.09, 0.96, 0.95, 1.06, 1.09, 1.54, 1.16, 1.01, 0.82, 1.04],
[ 1.14, 1.02, 1.04, 1.07, 1.02, 0.93, 1.09, 0.85, 1.47, 1.21],
[ 1.01, 1.35, 0.95, 0.81, 1.05, 0.85, 1.02, 0.88, 1. , 1.05],
[ 1.1 , 0.96, 1.13, 1.95, 1.06, 0.81, 1.02, 1.12, 0.95, 0.97],
[ 1.12, 0.9 , 1. , 1.08, 1.1 , 1.07, 1.7 , 0.94, 0.97, 0.93],
[ 1.64, 1.01, 1.25, 0.97, 0.93, 1.03, 0.81, 1.13, 1.02, 0.91],
[ 0.85, 0.95, 0.98, 0.99, 1.1 , 1.02, 1.04, 1.67, 0.96, 0.96],
[ 1.15, 0.97, 1.54, 0.95, 1.09, 1.14, 1.08, 0.9 , 0.91, 0.82],
[ 1.13, 0.95, 1.1 , 1.03, 1.89, 1.2 , 0.97, 1.04, 1.04, 1. ],
[ 0.93, 1.08, 0.84, 0.97, 0.95, 0.8 , 0.95, 0.98, 1.29, 1.46]])

portfolio = cvx.Variable(10)
riskfree = cvx.Variable()
scenario_returns = riskfree + joint_returns.T * portfolio
objective = scenario_probabilities * cvx.log(scenario_returns)
p = cvx.Problem(cvx.Maximize(objective),[scenario_returns >= 1e-5, riskfree + sum(portfolio) <= 1])

p.solve()


Reply to this email directly or view it on GitHubhttps://github.com/cvxgrp/cvxpy/issues/21
.

from cvxpy.

echu avatar echu commented on June 28, 2024 1

The log atom uses a different solver under the hood. It uses the cvxopt cpl solver. So you can change maxiters using

import cvxopt.solvers as cvxopt
solvers.options["maxiters"] = 1000

Or your favorite maxiters.

Eric

On Nov 5, 2013, at 10:29 AM, Travis Erdman [email protected] wrote:

Yes, the problem and solution are given on p. 1122 of the paper "A Strategy
Which Maximizes the Geometric Mean Return on Portfolio Investments" by
Vander Weide et al.

http://www.albany.edu/faculty/faugere/PhDcourse/GeomeanReturn.pdf

Per the paper, exp(objective.value) should be ~ 1.662; objective.value
should be ~ 0.508.

I tried to do a thorough search for increasing maxiter, but couldn't find
out how to do it.

On Tue, Nov 5, 2013 at 9:13 AM, Eric Chu [email protected] wrote:

Travis,

Do you happen to know what the optimal objective value is? I've increased
the maxiters for cvxopt and it seems to solve it, but I'm not sure if it's
accurate.

Eric

On Tue, Nov 5, 2013 at 1:23 AM, Travis Erdman [email protected]:

The code below (feel free to use it as a test case or example problem)
calculates the maximum expected log return for investment in 10
different
assets with 10 different outcome scenarios. The objective is similar to
that of acent.py, but it is a weighted sum of logs. The solvers do not
converge to the solution within maxiter, though it is a rather
straightforward problem. Any ideas?

import cvxpy as cvx
import cvxopt

scenario_probabilities =
cvx.numpy.array((0.3,0.15,0.1,0.1,0.06,0.06,0.06,0.06,0.06,0.05)).reshape(1,-1)

joint_returns = cvx.numpy.array( \
[[ 1.09, 0.96, 0.95, 1.06, 1.09, 1.54, 1.16, 1.01, 0.82, 1.04], \
[ 1.14, 1.02, 1.04, 1.07, 1.02, 0.93, 1.09, 0.85, 1.47, 1.21], \
[ 1.01, 1.35, 0.95, 0.81, 1.05, 0.85, 1.02, 0.88, 1. , 1.05], \
[ 1.1 , 0.96, 1.13, 1.95, 1.06, 0.81, 1.02, 1.12, 0.95, 0.97], \
[ 1.12, 0.9 , 1. , 1.08, 1.1 , 1.07, 1.7 , 0.94, 0.97, 0.93], \
[ 1.64, 1.01, 1.25, 0.97, 0.93, 1.03, 0.81, 1.13, 1.02, 0.91], \
[ 0.85, 0.95, 0.98, 0.99, 1.1 , 1.02, 1.04, 1.67, 0.96, 0.96], \
[ 1.15, 0.97, 1.54, 0.95, 1.09, 1.14, 1.08, 0.9 , 0.91, 0.82], \
[ 1.13, 0.95, 1.1 , 1.03, 1.89, 1.2 , 0.97, 1.04, 1.04, 1. ], \
[ 0.93, 1.08, 0.84, 0.97, 0.95, 0.8 , 0.95, 0.98, 1.29, 1.46]])

portfolio = cvx.Variable(10)
riskfree = cvx.Variable()
scenario_returns = riskfree + joint_returns.T * portfolio
objective = scenario_probabilities * cvx.log(scenario_returns)
p = cvx.Problem(cvx.Maximize(objective),[scenario_returns >= 1e-5,
riskfree + sum(portfolio) <= 1])

p.solve()


Reply to this email directly or view it on GitHub<
https://github.com/cvxgrp/cvxpy/issues/21>
.


Reply to this email directly or view it on GitHubhttps://github.com/cvxgrp/cvxpy/issues/21#issuecomment-27792365
.


Reply to this email directly or view it on GitHub.

from cvxpy.

erdman avatar erdman commented on June 28, 2024

Yes, the problem and solution are given on p. 1122 of the paper "A Strategy
Which Maximizes the Geometric Mean Return on Portfolio Investments" by
Vander Weide et al.

http://www.albany.edu/faculty/faugere/PhDcourse/GeomeanReturn.pdf

Per the paper, exp(objective.value) should be ~ 1.662; objective.value
should be ~ 0.508.

I tried to do a thorough search for increasing maxiter, but couldn't find
out how to do it.

On Tue, Nov 5, 2013 at 9:13 AM, Eric Chu [email protected] wrote:

Travis,

Do you happen to know what the optimal objective value is? I've increased
the maxiters for cvxopt and it seems to solve it, but I'm not sure if it's
accurate.

Eric

On Tue, Nov 5, 2013 at 1:23 AM, Travis Erdman [email protected]:

The code below (feel free to use it as a test case or example problem)
calculates the maximum expected log return for investment in 10
different
assets with 10 different outcome scenarios. The objective is similar to
that of acent.py, but it is a weighted sum of logs. The solvers do not
converge to the solution within maxiter, though it is a rather
straightforward problem. Any ideas?

import cvxpy as cvx
import cvxopt

scenario_probabilities =
cvx.numpy.array((0.3,0.15,0.1,0.1,0.06,0.06,0.06,0.06,0.06,0.05)).reshape(1,-1)

joint_returns = cvx.numpy.array(
[[ 1.09, 0.96, 0.95, 1.06, 1.09, 1.54, 1.16, 1.01, 0.82, 1.04],
[ 1.14, 1.02, 1.04, 1.07, 1.02, 0.93, 1.09, 0.85, 1.47, 1.21],
[ 1.01, 1.35, 0.95, 0.81, 1.05, 0.85, 1.02, 0.88, 1. , 1.05],
[ 1.1 , 0.96, 1.13, 1.95, 1.06, 0.81, 1.02, 1.12, 0.95, 0.97],
[ 1.12, 0.9 , 1. , 1.08, 1.1 , 1.07, 1.7 , 0.94, 0.97, 0.93],
[ 1.64, 1.01, 1.25, 0.97, 0.93, 1.03, 0.81, 1.13, 1.02, 0.91],
[ 0.85, 0.95, 0.98, 0.99, 1.1 , 1.02, 1.04, 1.67, 0.96, 0.96],
[ 1.15, 0.97, 1.54, 0.95, 1.09, 1.14, 1.08, 0.9 , 0.91, 0.82],
[ 1.13, 0.95, 1.1 , 1.03, 1.89, 1.2 , 0.97, 1.04, 1.04, 1. ],
[ 0.93, 1.08, 0.84, 0.97, 0.95, 0.8 , 0.95, 0.98, 1.29, 1.46]])

portfolio = cvx.Variable(10)
riskfree = cvx.Variable()
scenario_returns = riskfree + joint_returns.T * portfolio
objective = scenario_probabilities * cvx.log(scenario_returns)
p = cvx.Problem(cvx.Maximize(objective),[scenario_returns >= 1e-5,
riskfree + sum(portfolio) <= 1])

p.solve()


Reply to this email directly or view it on GitHub<
https://github.com/cvxgrp/cvxpy/issues/21>
.


Reply to this email directly or view it on GitHubhttps://github.com/cvxgrp/cvxpy/issues/21#issuecomment-27792365
.

from cvxpy.

erdman avatar erdman commented on June 28, 2024

Thank you, Eric. I'm glad to know how to adjust this for my future work. Examination of the solution indicates that I formulated this problem incorrectly. Correct formulation follows, with expected results in just 8 iterations.

import cvxpy as cvx
import cvxopt

scenario_probabilities = cvx.numpy.array((0.3,0.15,0.1,0.1,0.06,0.06,0.06,0.06,0.06,0.05)).reshape(1,-1)
joint_returns = cvx.numpy.array( \
    [[ 1.09,  0.96,  0.95,  1.06,  1.09,  1.54,  1.16,  1.01,  0.82,  1.04], \
    [ 1.14,  1.02,  1.04,  1.07,  1.02,  0.93,  1.09,  0.85,  1.47,  1.21], \
    [ 1.01,  1.35,  0.95,  0.81,  1.05,  0.85,  1.02,  0.88,  1.  ,  1.05], \
    [ 1.1 ,  0.96,  1.13,  1.95,  1.06,  0.81,  1.02,  1.12,  0.95,  0.97], \
    [ 1.12,  0.9 ,  1.  ,  1.08,  1.1 ,  1.07,  1.7 ,  0.94,  0.97,  0.93], \
    [ 1.64,  1.01,  1.25,  0.97,  0.93,  1.03,  0.81,  1.13,  1.02,  0.91], \
    [ 0.85,  0.95,  0.98,  0.99,  1.1 ,  1.02,  1.04,  1.67,  0.96,  0.96], \
    [ 1.15,  0.97,  1.54,  0.95,  1.09,  1.14,  1.08,  0.9 ,  0.91,  0.82], \
    [ 1.13,  0.95,  1.1 ,  1.03,  1.89,  1.2 ,  0.97,  1.04,  1.04,  1.  ], \
    [ 0.93,  1.08,  0.84,  0.97,  0.95,  0.8 ,  0.95,  0.98,  1.29,  1.46]])

portfolio = cvx.Variable(10)
scenario_returns = joint_returns.T * portfolio
objective = scenario_probabilities * cvx.log(scenario_returns) 
p = cvx.Problem(cvx.Maximize(objective),[sum(portfolio) == 1])

p.solve()

from cvxpy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.