# 非线性优化 | 非线性问题matlab+yalmip求解案例

## 2 完全直接调用matlab+yalmip求解

• abs: 添加绝对值约束
• max：添加约束

%定义变量
x=sdpvar(1);
y=sdpvar(1);
z=sdpvar(1);
u=sdpvar(1);
w=sdpvar(1);
%设置约束
con=[];
con=[con,(x-1)^2+(y-1)^2-1<=0];%二次非线性约束
con=[con,z+y-2<=0];
con=[con,z==abs(x)];%非线性约束
con=[con,u==y+4];
con=[con,w==max(z,u)];%非线性约束
con=[con,w>=0,z>=0];
%求解
ops = sdpsettings('verbose',1,'solver','cplex');%求解器设置
optimize(con,w,ops)
​
%结果
x=value(x)
y=value(y)
z=value(z)
u=value(u)
w=value(w)

CPXPARAM_MIP_Display                             1
Tried aggregator 2 times.
MIQCP Presolve eliminated 5 rows and 1 columns.
MIQCP Presolve modified 16 coefficients.
Aggregator did 5 substitutions.
Reduced MIQCP has 15 rows, 8 columns, and 40 nonzeros.
Reduced MIQCP has 2 binaries, 0 generals, 0 SOSs, and 0 indicators.
Reduced MIQCP has 1 quadratic constraints.
Presolve time = 0.00 sec. (0.05 ticks)
Probing time = 0.00 sec. (0.00 ticks)
MIP emphasis: balance optimality and feasibility.
MIP search method: dynamic search.
Parallel mode: deterministic, using up to 8 threads.
​
Node log . . .
Best integer =   4.999999e+00  Node =       0  Best node =   3.998578e+00
Best integer =   4.999997e+00  Node =       0  Best node =   3.999001e+00
Best integer =   4.000000e+00  Node =       0  Best node =   4.000000e+00
Flow cuts applied:  1
Gomory fractional cuts applied:  1
Cone linearizations applied:  13
​
ans =
​
包含以下字段的 struct:
​
yalmipversion: '20181012'
yalmiptime: 0.1245
solvertime: 0.3555
info: 'Successfully solved (CPLEX-IBM)'
problem: 0
​
x =    1.0000
y =  -6.9885e-09
z =    1.0000
u =    4.0000
w =    4.0000

Reduced MIQCP has 1 quadratic constraints

Cone linearizations applied:  13

|
8天前
|

- **算法理论:** 利用PSO优化的CNN-GRU，结合CNN的特征提取和GRU的记忆机制，进行时间序列预测。 - **CNN:** 通过卷积捕获序列的结构信息。 - **GRU:** 简化的LSTM，处理序列依赖。 - **预测步骤:** 1. 初始化粒子群，每粒子对应一组模型参数。 2. 训练并评估CNN-GRU模型的验证集MSE。 3. 使用PSO更新参数，寻找最佳配置。 4. 迭代优化直至满足停止准则。 
27 13
|
4天前
|

7 1
|
4天前
|

markdown 探索MATLAB2022a中WOA与DSN弱栅栏覆盖的创新融合，模拟鲸鱼捕食策略解决传感器部署问题。算法结合“搜索”、“包围”、“泡沫网”策略，优化节点位置以最大化复杂环境下的区域覆盖。目标函数涉及能量效率、网络寿命、激活节点数、通信质量及覆盖率。覆盖评估基于覆盖半径比例，旨在最小化未覆盖区域。 `
18 2
|
16天前
|

Matlab|基于改进鲸鱼优化算法的微网系统能量优化管理matlab-源码

31 2
|
8天前
|

11 0
|
2月前
|

114 1
|
2月前

95 1
|
2月前
|

38 1
|
2月前
|
Serverless

35 1
|
2月前
|

36 1