当前位置:网站首页>Supplement - nonlinear programming
Supplement - nonlinear programming
2022-07-26 21:39:00 【Exist ~ ~】
Example
1. Parameters with given values appear in the model
- Example

With the help of for loop , In the parameter a,b Solve the minimum value problem in the range
clc,clear
for a = 0:4
for b = [2,4,6,7]
f = @ (x) 4 * x(1) - a * x(1) -2 * x(2);
aa = [1,1;2,1;1,-b]
bb = [4;5;-2]
[x,y] = fmincon(f,rand(2,1),aa,bb,[],[],zeros(2,1))
fprintf('a = % d,b = % d when ,y = % f \n',a,b,y) % y The value is floating-point, so %f
x
end
end
% Output is :
a = 4,b = 7 when ,y = -7.999995
2. The constraints appear both linear and nonlinear
- Example

Linear constraints are written into the file of the main program
Write the objective function ff1
function y = ff1(x)
c1 = [2,3,1];
c2 = [3,1,0];
y = c1 * x + c2 * x.^2;
y = -y;
Writing nonlinear constraint functions ff2
function [f,g] = ff2(x)
f = [ x(1) + 2 * x(1)^2 + x(2) + 2 * x(2)^2 + x(3) - 10
x(1) + x(1)^2 + x(2) + x(2)^2 - x(3) - 50
2 * x(1) + x(1)^2 + 2 * x(2) + x(3) - 40];
g = x(1)^2 + x(3) - 2;
Run the main program
a = [-1,-2,0;-1,0,0];
b = [-1,0];
[x,y] = fmincon(@ff1,rand(3,1),a,b,[],[],[],[],@ff2)
x,y=-y
% Output is
x1 =2.3333
x2=0.1667
x3=-3.4444
y =18.0833
边栏推荐
- Arm Mali GPU的噩梦:三星、华为纷纷转向自研!
- 《暑假每日一题》Week 7:7.18 - 7.24
- 浏览器主页被篡改怎么办,主页被篡改恢复方法
- 25 cool interactive charts, one entry plotly
- Huawei released the top ten trends in 2025: 5g, robot, AI, etc
- Talk about TCP time_ WAIT
- 日本批准向韩出口EUV光刻胶,三星、SK海力士危机或将缓解
- 三星发布1.08亿像素图像传感器ISOCELL Bright HMX,小米将首发
- 测试员:“我有五年测试经验”HR: “不,你只是把一年的工作经验用了五年”
- Redis hash和string的区别
猜你喜欢

Alkbh1

【HCIA安全】用户认证

工业基础类IFC—提取模型结构树

留存收益率计算公式

【HCIA安全】双向NAT

Serial port communication failure

Registration conditions for information system project managers in the second half of 2022 (soft examination advanced)

基于Hough变换的直线检测(Matlab)

Live broadcast appointment award | senior consultant xuyanfei: how does efficiency measurement help efficient and sophisticated outsourcing management

Some unexpected bug records
随机推荐
Cfdiv1+2-pathwalks- (tree array + linear DP)
Redis hash和string的区别
:active vs :focus
六、微信小程序发布流程
拼多多获得搜索词推荐 API
LeetCode 练习——剑指 Offer II 005. 单词长度的最大乘积
Resize table columns
安全浏览器“隐身”模式可以查看历史记录吗?
word-break: break-all VS word-wrap: break-word
Pinduoduo gets search term recommendation API
美国再次发难:禁止承包商采购这5家中国公司的设备与技术
TypeScript中的类型断言
It is said that Samsung obtained EUV photoresist from Belgium
逻辑漏洞----任意账号注册
Attack and defense world ----- ics-07
商汤科技发布人脸识别一体机SensePass Pro
通过单击表头对表进行排序
【HCIA安全】NAT网络地址转换
Arm Mali GPU的噩梦:三星、华为纷纷转向自研!
25张炫酷交互图表,一文入门Plotly