当前位置:网站首页>线性规划例题 投资的收益与风险
线性规划例题 投资的收益与风险
2022-07-02 14:48:00 【__Rain】
、







得到拐点的 a a a 值运行一下求对应的变量值即可
clear;clc;
a=0;%投资风险
hold on
while a<0.05
c=[0.05 0.27 0.19 0.185 0.185];%目标函数的系数矩阵
A=[zeros(4,1),diag([0.025 0.015 0.055 0.026])];%不等式的系数矩阵
%把1*4的列向量和4*4的矩阵拼接起来,对角线为diag中的元素
b=a*ones(1,4);%生成全1的列向量,所有元素乘以a
%b是行向量还是列向量不影响结果
Aeq=[1 1.01 1.02 1.045 1.065];%等式左端中的系数矩阵
beq=1;%等式右端的值
lb=zeros(1,5);%变量x的下界
%lb是行向量还是列向量不影响结果
[x, Q]=linprog(-c,A,b,Aeq,beq,lb);%求最大值记得取-c
plot(a,-Q,'*r');% -Q为最终值
a=a+0.001;
end
xlabel('a'),ylabel('Q')
边栏推荐
猜你喜欢

TCP拥塞控制详解 | 2. 背景

亚马逊云科技 Community Builder 申请窗口开启

linux安装postgresql + patroni 集群问题

移动应用性能工具探索之路

Use the API port of the bridge of knowledge and action to provide resources for partners to access

Eth data set download and related problems

关于举办科技期刊青年编辑沙龙——新时代青年编辑应具备的能力及提升策略的通知...

福元医药上交所上市:市值105亿 胡柏藩身价超40亿

AP and F107 data sources and processing

What if the default browser cannot be set?
随机推荐
酒仙网IPO被终止:曾拟募资10亿 红杉与东方富海是股东
The computer comes with software to make the background color of the picture transparent (matting white background)
Just a coincidence? The mysterious technology of apple ios16 is even consistent with the products of Chinese enterprises five years ago!
Tech talk activity preview | building intelligent visual products based on Amazon kVs
[error record] error -32000 received from application: there are no running service protocol
几行代码搞定RPC服务注册和发现
Atcoder beginer contest 169 (B, C, D unique decomposition, e mathematical analysis f (DP))
ThreadLocal
C语言自定义函数的方法
Sword finger offer 24 Reverse linked list
远程办公对我们的各方面影响心得 | 社区征文
What will you do after digital IC Verification?
Sword finger offer 25 Merge two sorted linked lists
Sword finger offer 22 The penultimate node in the linked list
电脑自带软件使图片底色变为透明(抠图白底)
二、mock平台的扩展
宝宝巴士创业板IPO被终止:曾拟募资18亿 唐光宇控制47%股权
QStyle实现自绘界面项目实战(二)
移动应用性能工具探索之路
Vscode setting delete line shortcut [easy to understand]