学习视频:【零基础教程】老哥:数学建模算法、编程、写作和获奖指南全流程培训!
1. 蒙特卡洛模拟

1.1 解决求函数最值问题
 通过方程之间的联系,可以大致确定解的区间,进而解的方程。 
1.2 0-1规划问题

还可以解决导弹追踪,旅行商问题等。
2. Floyd最短距离(Shortest Path)
图论最短距离(Shortest Path)算法动画演示-Dijkstra(迪杰斯特拉)和Floyd(弗洛伊德) 
 经典的三层循环。  注意的一点就是,因为是无向图,所以权重邻接矩阵是一个对称矩阵。
for k=1:n % 中间节点k从1- n 循环
for i=1:n % 起始节点i从1- n 循环
for j=1:n % 终点节点j从1-n 循环
if dist(i,j)>dist(i,k)+dist(k,j)
dist(i,j)=dist(i,k)+dist(k,j);
path(i,j)=path(i,k);
end
end
end
end
3. 多元线性回归分析





内生性:未考虑到的变量于公式中已出现的变量相关。会影响系数。 若均不相关,则为外生性。
  

STATA软件使用

(1)定量数据 



4. 岭回归和lasso回归
 

5. LINGO软件的使用
链接 提取码:bni7
安装教程CSDN上面也有很多。LINGO 18.0安装教程
数学建模之十分钟学会LINGO(附建模实战)
编程注意点: ① 每个语句都需要分号来作为结束; ② 变量不区分大小写,X,x表示同一个变量注意区分; ③ Lingo 默认所有变量为大于等于 0 的数字,因而非负的条件不必多写; ④ 以 !开头,以 ;结束的语句是注释语句; ⑤ 一个线性规划中只含一个目标函数。(两个以上是多目标线性规划,Lingo 无法直接解);
数学建模之线性规划问题与LINGO软件的使用 
MATLAB解法:
% 设x1桶生产A1牛奶,x2桶生产A2牛奶
% max y = 72*x1 + 64*x2(3*24 4*16)
% x1 + x2 <= 50
% 12*x1 + 8*x2 <=480
% 3*x1 + 4*x2 <= 100
% x1, x2 >= 0
f = [-72; -64];
a = [1, 1; 12, 8; 3, 4];
b = [50; 480; 100];
aeq = [0, 0];
beq = 0;
intcon=[1 2];
[x, y] = intlinprog(f,intcon,a,b,aeq,beq,zeros(2, 1),[inf, inf]);
x; y=-y;
sprintf('生产A1牛奶%dkg,A2牛奶%dkg,获利%d元',x(1),x(2), y)
all_time = 12 * x(1) + 8 * x(2);
money_max = y / all_time + rem(y, all_time);
sprintf('付出的工资最多是每小时%f元',money_max)
% max y = 72*x1 + 64*x2 - 35(x1 + x2) ( 37 29 )
f1 = [-37; -29];
[x, y] = intlinprog(f1,intcon,a,b,aeq,beq,zeros(2, 1),[inf, inf]);
if(-y > 0)
sprintf("35元可买到1桶牛奶,买!每天最多买多少%d桶", x(1)+x(2))
else
sprintf("35元可买到1桶牛奶,不买!")
end
% max y = 90*x1 + 64*x2(3*30 4*16)
f = [-90; -64];
[x1, y1] = intlinprog(f,intcon,a,b,aeq,beq,zeros(2, 1),[inf, inf]);
x1; y1=-y1;
if x1 == x
sprintf('计划不变')
else
sprintf('生产A1牛奶%dkg,A2牛奶%dkg,获利%d元',x1(1),x1(2), y1)
end

%%
% 设x1桶生产 3*x1 kg A1牛奶,x2桶生产 4*x2 kgA2牛奶
% 设 x3kg的A1 生产B1牛奶,x4kg的A2 生产B2牛奶
% max y = 72*x1 + 64*x2 + 32.8*x3 + 21.75*x4 ( (44-3)*0.8 (32-3)*0.75 )
% x1 + x2 <= 50
% 12*x1 + 8*x2 <=480
% 3*x1 + 4*x2 <= 100
% x3 <= 3*x1 -3*x1 + x3 <= 0
% x4 <= 4*x2 -4*x2 + x4 <= 0
% x1, x2 >= 0
f = [-72; -64; -32.8; -21.75];
a = [1, 1, 0, 0;
12, 8, 0, 0;
3, 4, 0, 0;
-3, 0, 1, 0;
0, -4, 0, 1];
b = [50; 480; 100; 0; 0];
intcon=[1 4];
[x, y] = intlinprog(f,intcon,a,b,[],[],zeros(4, 1),[]);
x; y=-y;
sprintf('生产A1牛奶%dkg,A2牛奶%dkg,生产B1牛奶%dkg,生产B2牛奶%dkg,获利%d元',3*x(1),4*x(2),0.8*x(3),0.75*x(4) ,y)
%%
% max y = 72*x1 + 64*x2 + 32.8*x3 + 21.75*x4 -30 ( (44-3)*0.8 (32-3)*0.75 )
% x1 + x2 <= 50 + 1
b1 = [51; 480; 100; 0; 0];
intcon=[1 4];
[x1, y1] = intlinprog(f,intcon,a,b1,[],[],zeros(4, 1),[]);
x1;
y1 = -y1 -30;
if y1 > y
sprintf("应该投资")
else
sprintf("不投资")
end
%%
% 12*x1 + 8*x2 <=480 + 1
b2 = [50; 481; 100; 0; 0];
intcon=[1 4];
[x2, y2] = intlinprog(f,intcon,a,b2,[],[],zeros(4, 1),[]);
x2;
y2 = -y2 -3;
if y2 > y
sprintf("应该投资")
else
sprintf("不投资")
end
%%
% max y = 72*x1 + 64*x2 + 32.8*x3 + 21.75*x4 ( (44-3)*0.8 (32-3)*0.75 )
for i = 1:10
f1 = [-72; -64; -32.8+20*(rand()-0.5); -21.75+20*(rand()-0.5)];
intcon=[1 4];
[x3, y3] = intlinprog(f1,intcon,a,b,[],[],zeros(4, 1),[]);
y3 = -y3;
if y3 ~= y
sprintf("有影响")
end
end
%%
% 3*x1>=10
a1 = [1, 1, 0, 0;
12, 8, 0, 0;
3, 4, 0, 0;
-3, 0, 1, 0;
0, -4, 0, 1;
-3, 0, 0, 0];
b1 = [50; 480; 100; 0; 0; 10];
intcon=[1 4];
[xs, ys] = intlinprog(f,intcon,a1,b1,[],[],zeros(4, 1),[]);
if ys > y
sprintf("更好的收益")
elseif ys == y
sprintf("一样的收益")
else
sprintf("会亏损")
end
|