【BI学习作业20-常见的规划问题1】


1.思考题

1.1常见的规划问题都包括哪些?

要求

简要说明常见的规划问题

规划问题

1.LP:Linear Programming 线性规划

研究线性约束条件下线性目标函数的极值问题

2.ILP:Integer Linear Programming 整数线性规划

全部决策变量必须为整数

3.MIP:Mixed Integer Programming 混合整数规划

混合整数规划是LP的一种,其中部分的决策变量是整数(不要求全部都是整数)

4.VRP:Vehicle Routing Problem 车辆路径问题

1.2常用的规划工具包都有哪些?

要求

简要说明常用的规划工具包有哪些

规划工具

  • pulp

只用于线性模型,包括如整数规划、01规划,还是混合整数线性规划 MILP

  • ortools

1.Google开发,用于优化的开源软件
2.可以解决车辆路径、流程、整数和线性规划等问题
3.提供了C++,Python,Java,.NET接口

1.3TSP与VRP问题的关系是怎样的?

简要说明TSP, VRP的关系

TSP问题即旅行商问题,经典的TSP可以描述为:一个商品推销员要去若干个城市推销商品,该推销员从一个城市出发,需要经过所有城市后,回到出发地。应如何选择行进路线,以使总的行程最短。从图论的角度来看,该问题实质是在一个带权完全无向图中,找一个权值最小的哈密尔顿回路。

车辆路径规划问题(Vehicle Routing Problem,VRP)一般指的是:对一系列发货点和收货点,组织调用一定的车辆,安排适当的行车路线,使车辆有序地通过它们,在满足指定的约束条件下(例如:货物的需求量与发货量,交发货时间,车辆容量限制,行驶里程限制,行驶时间限制等),力争实现一定的目标(如车辆空驶总里程最短,运输总费用最低,车辆按一定时间到达,使用的车辆数最小等)。

由此定义不难看出,旅行商问题(Traveling Saleman Problem,TSP)是VRP的特例。

2.编程题

2.1农田承包收益最大化问题

一个农民承包了6块耕地共300亩,准备播种小麦,玉米,水果和蔬菜四种农产品,各种农产品的计划播种面积、每块土地种植不同农产品的单产收益如下:
在这里插入图片描述
目标

求解最高的收益值,以及不同农产品在不同地块上的种植安排可以采用任何优化工具,比如scipy, pulp, ortools

任务

1.使用任何优化工具完成代码
2.结果正确

import pulp
from pulp import *


items = ['wheat', 'corn', 'fruit', 'vegetables']

income = {'wheat': 76, 
         'corn': 88, 
         'fruit': 96, 
         'vegetables': 40}


land1 = {'wheat': 500, 
         'corn': 800, 
         'fruit': 1000, 
         'vegetables': 1200}

land2 = {'wheat': 550, 
         'corn': 700, 
         'fruit': 960, 
         'vegetables': 1040}

land3 = {'wheat': 630, 
         'corn': 600, 
         'fruit': 840, 
         'vegetables': 980}

land4 = {'wheat': 1000, 
         'corn': 950, 
         'fruit': 650, 
         'vegetables': 860}

land5 = {'wheat': 800, 
         'corn': 900, 
         'fruit': 600, 
         'vegetables': 880}

land6 = {'wheat': 700, 
         'corn': 930, 
         'fruit': 700, 
         'vegetables': 780}


#创建问题实例,求最大极值
prob = LpProblem("The CatFood Problem", LpMaximize)

#构建Lp变量字典,变量名以item开头,如item_chicken,下界是0
item_vars = LpVariable.dicts("item", items, lowBound=0, upBound=300)
print(item_vars)

#添加目标方程
prob += lpSum([income[i]*item_vars[i] for i in items])

#添加约束条件
prob += lpSum([item_vars[i] for i in items]) == 300
prob += lpSum([land1[i] * item_vars[i] for i in items]) <= 42
prob += lpSum([land2[i] * item_vars[i] for i in items]) <= 56
prob += lpSum([land3[i] * item_vars[i] for i in items]) <= 44
prob += lpSum([land4[i] * item_vars[i] for i in items]) <= 39
prob += lpSum([land5[i] * item_vars[i] for i in items]) <= 60
prob += lpSum([land6[i] * item_vars[i] for i in items]) <= 59

#求解
prob.solve()
print("Status:", LpStatus[prob.status])
# 查看解
for i in items:
  print('{} = {}'.format(item_vars[i],item_vars[i].value()))

结果

{'wheat': item_wheat, 'corn': item_corn, 'fruit': item_fruit, 'vegetables': item_vegetables}
Status: Infeasible
item_wheat = 0.0
item_corn = 0.0
item_fruit = 0.1
item_vegetables = 0.0
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

水花

您的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值