当前位置:网站首页>【数学建模】整数规划
【数学建模】整数规划
2022-08-06 08:49:00 【开心星人】
司守奎 《数学建模算法与应用》 第二版

0-1型
相互排斥的约束条件
5x1+4x2≤24 或 7x1+3x2≤45

如果有m个互相排斥的约束条件
指派问题
拟分配n人去做n项工作,每人做且仅做一项工作,若分配第i人去做第j项工作,需花费c单位时间,问应如何分配工作才能使工人花费的总时间最少?
蒙特卡洛法(随机取样法)
y=x2、y=12-x与x轴在第一象限围成一个曲边三角形。设计一个随机实验,求该图形面积的近似值。
在矩形区域[0,12]×[0,9]上产生服从均匀分布的107个随机点,统计随机点落在曲边三角形的频数,则曲边三角形的面积近似为上述矩形的面积乘以频率。
clc,clear
×=unifrnd(0,12,[1,10000000]);
y=unifrnd(0,9,[1,10000000]);
pinshu =sum(y<x.^2 &x<=3)+sum(y <12-x&x>=3);
area_appr =12 *9 *pinshu/10^7

编写文件mengte.m,目标函数f和约束向量g
function[f,g]=mengte(x);
f=x(1)^2+x(2)^2+3*x(3)^2+4*x(4)^2+2*x(5)^2-8*x(1)-2*x(2)-3*x(3)-x(4)-...
2*x(5);
g=[
sum(x)-400
x(1)+2*x(2)+2*x(3)+x(4)+6*x(5)-800
2*x(1)+x(2)+6*x(3)-200
x(3)+x(4)+5*x(5)-200
];
主函数
format compact;
rand('state',sum(clock)); % 初始化随机数发生器
p0=0;
tic % 计时开始
for i=1:10^6
x=randi([0,99],1,5); % 产生1行5列的区间[0,99]上的随机整数
[f,g]=mengte(x);
if all(g<=0)
if p0<f
x0=0;p0=f; % 记录下当前较好的解
end
end
end
x0,p0
toc % 计时结束
边栏推荐
猜你喜欢

Can the code signing certificate solve the software being alerted by antivirus software?

LeetCode——1047. 删除字符串中的所有相邻重复项

LeetCode - 1047. Remove all adjacent duplicates in a string

js simulates the function of dynamically deleting messages

按钮只能点击一次

CPU Architecture at a Glance

石原子科技正式加入openGauss社区

Button can only be clicked once

代码签名证书可以解决软件被杀毒软件报毒提醒吗?

测试用例设计方法-场景法详解
随机推荐
回头再看ResNet——深度学习史上的关键一步
Day 17 (16 day bpdus related knowledge and STP configuration)
Exchange comprehensive experiment (to be supplemented)
40多条令人爆笑的注释
LeetCode——1047. 删除字符串中的所有相邻重复项
20220803模拟
Advanced Programming in UNIX Environment - Chapter 2
BigEvent Demo
No, no, no, it's 2022, you don't know the principle of Jmeter, right?
QianBase Operation and Maintenance Practical Commands
I set the global mapping table prefix in yml, but the database does not recognize it
quickbi 中 数据集sql 使用 if
About the third parameter of np.zeros(): c represents similar to c language, row priority; F represents column priority record
卡尔曼滤波器(目标跟踪一)(上)
读书笔记(二)——《被讨厌的勇气》
QT配置,缺失.dll
Detailed explanation of Mysql things (important)
MySQL主外键讲解
【内网横移方法与实验】
字节跳动最爱问的智力题总结