搜索内容 搜索用户

# [未答复] 非线性优化中约束含有整数选择什么求解器

jingyi.yang 发表于 2021-11-24 16:54:54
 本帖最后由 jingyi.yang 于 2021-11-24 16:58 编辑
%目标函数用m文件复制代码

2 条回复

## 倒序浏览

jingyi.yang 发表于 2021-11-24 16:59:07
 %目标函数用m文件 fun = @eta; %第14到17变量为整数 intcon = 14:17; x0 = [1e5,0.002,0.002,0.002,0.002,1.05,1.05,1.05,1.05,0.05,0.1,0.1,0.05,2,10,10,2,0,0.01,0];    %初始量 %线性不等式约束 A = [     -1,zeros(1,19);     1,zeros(1,19);     0,-1,zeros(1,18);     0,1,zeros(1,18);     zeros(1,2),-1,zeros(1,17);     zeros(1,2),1,zeros(1,17);     zeros(1,3),-1,zeros(1,16);     zeros(1,3),1,zeros(1,16);     zeros(1,4),-1,zeros(1,15);     zeros(1,4),1,zeros(1,15);     zeros(1,5),-1,zeros(1,14);     zeros(1,5),1,zeros(1,14);     zeros(1,6),-1,zeros(1,13);     zeros(1,6),1,zeros(1,13);     zeros(1,7),-1,zeros(1,12);     zeros(1,7),1,zeros(1,12);     zeros(1,8),-1,zeros(1,11);     zeros(1,8),1,zeros(1,11);     zeros(1,9),-1,zeros(1,10);     zeros(1,9),1,zeros(1,10);     zeros(1,10),-1,zeros(1,9);     zeros(1,10),1,zeros(1,9);     zeros(1,11),-1,zeros(1,8);     zeros(1,11),1,zeros(1,8);     zeros(1,12),-1,zeros(1,7);     zeros(1,12),1,zeros(1,7);     zeros(1,13),-1,zeros(1,6);     zeros(1,13),1,zeros(1,6);     zeros(1,14),-1,zeros(1,5);     zeros(1,14),1,zeros(1,5);     zeros(1,15),-1,zeros(1,4);     zeros(1,15),1,zeros(1,4);     zeros(1,16),-1,zeros(1,3);     zeros(1,16),1,zeros(1,3);     zeros(1,18),-1,zeros(1,1);     zeros(1,18),1,zeros(1,1);     ];          b = [     -1e5;     1e6;     -0.002;     0.004;     -0.002;     0.004;     -0.002;     0.004;     -0.002;     0.004;     -1.05;     4;      -1.05;     4;      -1.05;     4;      -1.05;     4;     -0.05;     0.08;     -0.1;     0.15;     -0.1;     0.15;     -0.05;     0.08;     -1;     3;     -10;     20;     -10;     20;     -1;     3;     -0.01;     0.15;             ]; %等式约束 Aeq = [         zeros(1,17),1,0,0;         zeros(1,19),1;         ]; beq = [         0;         0;         ]; %用MILP的话目标函数必须是double输入 %[x,fval] = intlinprog(fun,intcon,A,b,Aeq,beq,[],[],x0);

jingyi.yang 发表于 2021-11-24 17:00:16
 详细代码见一楼，不知道为什么帖子没发出来
 您需要登录后才可以回帖 登录 | 注册 本版积分规则 回帖后跳转到最后一页