python中quadratic,Python: Using CVXOPT for quadratic programming
问题
I'm using CVXOPT to do quadratic programming to compute the optimal weights of a potfolio using mean-variance optimization. There is a great example at http://abel.ee.ucla.edu/cvxopt/userguide/coneprog.html#quadratic-programming. However, the arguments are in a regularized form (according to the author). The example is a basic version. I am looking to do a bit of a more complex problem where:
min:
x'Sx
s.t.:
x'a >= g
x'1 = 0
x >= -Wb
x <= c1 - Wb
where:
x: active weights of assets (active weight = portfolio weight - benchmark weight)
S: covariance matrix of asset returns
a: expected stock excess returns
g: target gain
Wb: weights of assets in the benchmark
c: upper limit (weight) of any asset in the portfolio
Assume all the variables are computed or known.
The basic example presented in the documentation:
min:
x'Sx
s.t.
p'x >= g
1'x = 1
Where p are the asset returns.
What I do not know (referring to the code at http://abel.ee.ucla.edu/cvxopt/examples/book/portfolio.html and optimization problem above):
1.I think these arguments setup the constraints but I'm not entirely sure:
G = matrix(0.0, (n,n))
G[::n+1] = -1.0
h = matrix(0.0, (n,1))
A = matrix(1.0, (1,n))
b = matrix(1.0)
2.I believe this is part of the minimization problem in "regulated form", which I'm not sure what means:
mus = [ 10**(5.0*t/N-1.0) for t in xrange(N) ]
3.What the arguments to qp are (solver.qp is the quadratic optimizer):
xs = [ qp(mu*S, -pbar, G, h, A, b)['x'] for mu in mus ]
Looking at the documentation, I'm pretty sure that mu*S (the first argument) is the objective function to be minimzed and -pbar are the returns. This looks like a maximization problem however (maximizing negative returns).
I do not know, however how the other arguments are used.
I am looking for help using the optimizer given my minimization problem and constraints above.
回答1:
I read the docs and I think you have to use the function with the following parameters. I assume that x has size n:
P = S
q = (0,....0)
A = (1, ...... 1)
b = (0)
G is vertically stacked from
-a
+I_n
-I_n
where I_n is the identity matrix of size n x n . And the corresponding right hand side h is
-g
Wb
...
Wb
C1-Wb
...
C1-Wb
That is: one -g, n times Wb and n times C1-Wb.
HTH.
来源:https://stackoverflow.com/questions/7572698/python-using-cvxopt-for-quadratic-programming
python中quadratic,Python: Using CVXOPT for quadratic programming相关推荐
- 在python中安装python库
1.安装numpy库 win+R -> cmd ->where python(有种情况是输入where python之后,出现" 'where不是内部或外部命令,也不是可运行的 ...
- python中年月日,python日期和时间
今天是第17天,在Python中通常用时间戳,时间字符串和元组三种方式表示,今天学习的是time和datetime常用时间和日期函数的用法 一.日期和时间的处理 1,时间戳 指1970年1月1日0时0 ...
- python中变量,Python中的变量、数据类型、运算符
Python第四课 Python中的变量.数据类型.运算符 Hello,小伙伴们,今天我们来聊一聊Python里面的变量.数据类型.运算符. 一. 变量:什么是变量呢? 我们来看这样一个例子:李四在银 ...
- python中fig_matplotlib python:fig.figimage和fig.savefig的图形大小
我正在尝试将png图像添加到在 python中使用matplotlib创建的绘图中. 这是我的情节代码 import matplotlib as mpl mpl.use('Agg') import m ...
- python中变量,python中变量的概念
python中变量的概念 在python中,变量就是一种标识符, 它是数据的名字,更专业的理解,变量是内存中数据的引用, 编程语言里的变量和初中学习代数时的方程变量很相似. 前面学习数字类型,bool ...
- python中获取python版本号的方法
#!/usr/bin/python # 第1种方法 import platform print(platform.python_version()) 1 2 3 >>> impo ...
- Python中使用python -m pip install --upgrade pip升级pip时老是不成功
场景 在使用python -m pip install --upgrade pip进行pip升级时,每次到最后就是报一大堆红色,最终升级不成功. 实现 使用默认的镜像源时间过长就会没响应,使用豆瓣的镜 ...
- callable python中意义,Python之callable
callable(object) return True if the object argument appears callable, False if not. 可以检查一个对象是否是可调用的( ...
- python中mxnet_mxnet Python 笔记
1.查看mxnet的版本 import mxnet as mx mx.__version__ 2.扩展nd的维度 image_data = mx.random.normal(shape = (3, 1 ...
- 如何注释python中html,Python在HTML中提取带注释的代码,python,html,被
假设被注释代码段如下: html=""" """ 如果直接对此代码段使用pyquery转换并提取 from pyquery import P ...
最新文章
- Rushcrm:客户关系管理适合的才是好的
- java opencv 开发环境_Java + opencv学习:在Eclipse下配置基于Java的OpenCV开发环境
- Linux - Sysstat [ All-in-One System Performance and Usage Activity Monitoring Tool For Linux]
- 【转载】MySQL Show命令总结
- AcWing 320. 能量项链
- 使用Bootstrap制作右键单击自定义菜单
- D/E盘根目录出现Msdia80.dll操作;dllregisterserver调用失败错误代码0x80004005 解决
- 树莓派的浏览器无法上网
- 炸!微信Windows版可以刷朋友圈了
- EKL日志平台架构概括
- spring boot 作业管理系统
- 莘城苑:面包种类选择
- 干接点信号_百度百科
- 如何让销售管理更高效?
- 知识竞赛答题小程序的管理后台搭建教程
- 即时聊天APP(一)
- android开发——分秒计时器(可 开始/暂停/继续/停止)
- carton num_Carton先生–世界上第一个卡通系列MadeWithUnity
- Hotspot源码解析一
- 锐起无盘xp 1.5 试装手记(转)