当前位置:网站首页>补充—非线性规划
补充—非线性规划
2022-07-26 20:44:00 【存在~~】
例题
1.模型中出现给出取值的参数
- 例题

借助for循环,在参数a,b范围内求解最小值问题
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时,y = % f \n',a,b,y) % y值为浮点型所以%f
x
end
end
% 输出为:
a = 4,b = 7时,y = -7.999995
2.约束条件同时出现线性和非线性
- 例题

线性约束条件写入主程序的文件中
编写目标函数ff1
function y = ff1(x)
c1 = [2,3,1];
c2 = [3,1,0];
y = c1 * x + c2 * x.^2;
y = -y;
编写非线性约束函数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;
运行主程序
a = [-1,-2,0;-1,0,0];
b = [-1,0];
[x,y] = fmincon(@ff1,rand(3,1),a,b,[],[],[],[],@ff2)
x,y=-y
% 输出为
x1 =2.3333
x2=0.1667
x3=-3.4444
y =18.0833
边栏推荐
- MySQL的JDBC操作及入门案例
- Remember the idea of solving the problem of invalid bound statement xxxxx once
- Basic use of livedatade
- [question] browser get request with token
- Smooth scroll to element
- 1-《PyTorch深度学习实践》-线性模型
- 【MySQL系列】-索引知多少
- Placeholder of contentedable element
- Broadcast voice H5 speechsynthesisutterance
- [virtual machine data recovery] data recovery of XenServer virtual machine unavailable due to unexpected power failure
猜你喜欢

六、微信小程序发布流程

Flash source code outline

【MySQL系列】-索引知多少

SPI configuration

2022 open atom global open source summit agenda express | list of sub forum agenda on July 27

工业基础类IFC—提取模型结构树
![[download materials of harmoniyos topics] HDD Hangzhou station · offline salon focuses on application innovation to show the ecological charm of Hongmeng](/img/62/9e2ff0dc2c8b049fd32ad56334a0c0.jpg)
[download materials of harmoniyos topics] HDD Hangzhou station · offline salon focuses on application innovation to show the ecological charm of Hongmeng

Test cases should never be used casually, recording the thinking caused by the exception of a test case

The hardest lesson we learned from the crypto Market

【HCIA安全】用户认证
随机推荐
微服务化解决文库下载业务问题实践
Browser browser cache
我们被一个 kong 的性能 bug 折腾了一个通宵
JVM learning - memory structure - program counter & virtual machine stack & local method stack & heap & method area
基于Hough变换的直线检测(Matlab)
七、微信小程序运行报错:Error: AppID 不合法,invalid appid
IT系统为什么需要可观测性?
如何借助自动化工具落地DevOps|含低代码与DevOps应用实践
【HCIA安全】双向NAT
Placeholder of contentedable element
encodeURI VS encodeURIComponent
Devops has been practiced for many years. What is the most painful thing?
contenteditable 元素的placeholder
Industrial basic IFC - extract model structure tree
(C language) a brief introduction to define
[download materials of harmoniyos topics] HDD Hangzhou station · offline salon focuses on application innovation to show the ecological charm of Hongmeng
:active vs :focus
Six instructions of Memcache based caching mechanism
(C语言)浅识#define
LeetCode 练习——剑指 Offer II 005. 单词长度的最大乘积