当前位置:网站首页>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
边栏推荐
- Mobile phone \ landline call forwarding setting method
- 织梦文档关键词维护不管用
- Serial port communication failure
- VI and VIM text editors
- <button> 与 <input type=“button“ />
- In depth study of efcore migrations
- FreeRTOS个人笔记-事件
- 25张炫酷交互图表,一文入门Plotly
- The United States once again challenged: Forbidding contractors to purchase the equipment and technology of these five Chinese companies
- Calculation formula of retained earnings rate
猜你喜欢

彻底搞通服务发现的原理和实现
![[HCIA security] user authentication](/img/6f/0ab6287eac36a4647dc2a0646ba969.png)
[HCIA security] user authentication

DeepFake捏脸真假难辨,汤姆·克鲁斯比本人还像本人!

Flash source code outline

kalibr标定realsenseD435i --多相机标定

Difference between redis hash and string
![[question] browser get request with token](/img/95/f0b7186f930c014495414c3fcdaa6e.png)
[question] browser get request with token

安全浏览器“隐身”模式可以查看历史记录吗?

Mobile phone \ landline call forwarding setting method

golang版本管理gvm
随机推荐
event. preventDefault VS return false
golang版本管理gvm
Object. getOwnPropertyNames() VS Object.keys()
如何在一个项目中使用多种不同的语言?
逻辑漏洞----任意账号注册
Filtering and distortion
织梦提示DedeCMS Error:Tag disabled:php!
Is it safe for Huishang futures to open an account? What should Huishang futures pay attention to when opening an account?
Ros2 node communication realizes zero copy
Alkbh1
Remember the idea of solving the problem of invalid bound statement xxxxx once
Selenium自动化测试面试题全家桶
Line detection based on Hough transform (matlab)
MySQL的JDBC操作及入门案例
Show load indicator when loading iframe
Summer vacation daily question week 7:7.18 - 7.24
Some unexpected bug records
Registration conditions for information system project managers in the second half of 2022 (soft examination advanced)
7、 Wechat applet running error: error: illegal appid, invalid appid
Summary of common interview questions of computer composition principle, including answers