数学建模校内赛-整数规划模型-抛砖玉

1.先记录一下自己踏进去的坑

1.首先是python的scipy对应的线性规划库不可以以二维数组作为参数,cvxpy的决策变量也最高为二维
2.cvxpy库最好还是安装37版本,如何建立多环境并安装包在我的另一篇博客有介绍
3.cvxpy,一定要用resluts=prob.solve(solver=cp.CPLEX),另外那个GLPK_MI别用
我也看不懂那个求解器好点在这里插入图片描述

赛题

在这里插入图片描述

模型

在这里插入图片描述
Objective function(1在这里插入图片描述
): Meet the minimum cost
Constraint condition(2): Meet carbohydrate intake constraints
Constraint condition(3): Meet the restriction on fat intake
Constraint condition(4): Meet the restriction on calorie intake
Constraint condition(5): Meet the restriction on calcium intake
Constraint condition(6): Meet the restriction on phosphorus intake
Constraint condition(7): Meet the restriction of iron intake
Constraint condition(8): Meet the restriction of vitamin A intake
Constraint condition(9): Meet the restriction on vitamin B2 intake
The intake data of various nutrients are from the reasonable dietary composition index recommended by Chinese Nutrition Society and Baidu Encyclopedia.

代码

#from scipy.optimize import linprog
import xlrd
import numpy as np
import cvxpy as cp
from scipy.optimize import linprog
workbook = xlrd.open_workbook('fo.xlsx')#Extract data from a data set
sheet1= workbook.sheet_by_index(0)
Afat=sheet1.col_values(colx = 0)
Acar=sheet1.col_values(colx = 1)
Apro=sheet1.col_values(colx = 2)
Ava=sheet1.col_values(colx = 3)
Avb2=sheet1.col_values(colx = 4)
Avc=sheet1.col_values(colx = 5)
Ak=sheet1.col_values(colx = 6)
Aca=sheet1.col_values(colx = 7)
Ap=sheet1.col_values(colx = 8)
Afe=sheet1.col_values(colx = 9)
Aze=sheet1.col_values(colx = 10)
Aka=sheet1.col_values(colx = 11)
Ama=sheet1.col_values(colx = 12)
end1=sheet1.col_values(colx =
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

lu750310

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

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

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

打赏作者

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

抵扣说明:

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

余额充值