『壹』 為什麼python線性規劃變數位數不變
python線性規劃變數位數不變的原因是:名稱一般叫做變數,表明它們引用的數據可以變化,而名稱保持不變。看到變數也叫做名稱(name),這是Python的叫法。
『貳』 Python有哪些可以做帶約束的二次線性規劃的包
APM Python
- APM Python is free optimization software through a web service.
Nonlinear Programming problem are sent to the APMonitor server and
results are returned to the local Python script. A web-interface
automatically loads to help visualize solutions, in particular dynamic
optimization problems that include differential and algebraic equations.
Default solvers include APOPT, BPOPT, and IPOPT. Pre-configured modes
include optimization, parameter estimation, dynamic simulation, and
nonlinear control.
Coopr - The Coopr software project integrates a variety of Python optimization-related packages.
CVOXPT
- CVXOPT is a free software package for convex optimization based on
the Python programming language. It can be used with the interactive
Python interpreter, on the command line by executing Python scripts, or
integrated in other software via Python extension moles. Its main
purpose is to make the development of software for convex optimization
applications straightforward by building on Python』s extensive standard
library and on the strengths of Python as a high-level programming
language.
OpenOpt
(license: BSD) contains connections to tens of solvers and has some own
Python-written ones, e.g. nonlinear solver with specifiable accuracy: interalg, graphic output of convergence and some more numerical optimization "MUST HAVE" features. Also OpenOpt can solve FuncDesigner
problems with automatic differentiation, that usually work faster and
gives more precise results than finite-differences derivatives
approximation.
PuLP
- PuLP is an LP modeler written in python. PuLP can generate MPS or LP
files and call GLPK, COIN CLP/CBC, CPLEX, and GUROBI to solve linear
problems.
Pyomo
- The Python Optimization Modeling Objects (Pyomo) package is an open
source tool for modeling optimization applications in Python. Pyomo can
be used to define symbolic problems, create concrete problem instances,
and solve these instances with standard solvers. Pyomo provides a
capability that is commonly associated with algebraic modeling languages
such as AMPL, AIMMS, and GAMS, but Pyomo's modeling objects are
embedded within a full-featured high-level programming language with a
rich set of supporting libraries. Pyomo leverages the capabilities of
the Coopr software library, which integrates Python packages for
defining optimizers, modeling optimization applications, and managing
computational experiments.
scipy.optimize - some solvers written or connected by SciPy developers.
pyOpt
- pyOpt is a package for formulating and solving nonlinear constrained
optimization problems in an efficient, reusable and portable manner
(license: LGPL).
『叄』 Python有哪些可以做帶約束的二次線性規劃的包
線性規劃立足於求滿足所有約束條件的最優解,而在 實際問題中,可能存在相互矛盾的約束條件.目標規劃可 以在相互矛盾的約束條件下找到滿意解.
『肆』 python有能解決層次線性規劃的庫嗎
約束條件沒時間細看了,根據你的代碼改了一下,沒有語法錯誤了! !集部分; sets: month/1..12/: it, dt, st, rt, ht; endsets !目標函數; MAX=@sum(month(I): 5400*DT(I) + 2400.110*HT(I)); !約束條件; @for(month(I): Rt(I) - Dt(I) >=20; It(。
『伍』 python的庫怎麼寫的
庫包括了一些常量,函數方法,以及類
比如說你要做一個叫做修理工具的庫
這個庫里就要有一些常用的手動工具,扳手,螺絲刀之類的。這相當於常量
然後還要有一些電動工具,手電筒轉之類的。函數方法。
最後還不能少的就是說明書。沒有說明搞修理,那是丈二和尚摸不著頭腦。這個相當於類。
然後造一個維修間。把這些手動工具,電動工具,圖紙說明說都找地方放好。
不可缺少的還有一個工作台。 有了這些庫就成功構造好了。
需要用什麼就到庫里去拿。
python的庫實際就是一個文件目錄,在這個目錄中包含了庫的初始化文件,以及包含各種常量,方法,類的文件。最後還要設置python的環境變數,讓python能夠找到庫在哪裡。
『陸』 python的pulp庫解決線性規劃問題
戰術決策問題,某戰略轟炸機隊指揮官得到了摧毀敵方坦克生產能力的命令. 根據情報, 敵方有四個生產坦克部件的工廠, 位於不同的地方. 只要破壞其中任一工廠的生產設施就可以有效地停止敵方坦克的生產. 根據分析, 執行該任務的最大因素是汽油短缺, 為此項任務只能提供48000加侖汽油.而對於任何一種轟炸機來說, 不論去轟炸哪一個工廠都必須有足夠往返的燃料和100加侖備余燃料.該轟炸機隊現有重型和中型兩種轟炸機, 其燃油消耗量及數量見下表
編號 飛機類型 每千米耗油量 飛機駕數
1 重型 1/2 48
2 中型 1/3 32
各工廠距離空軍基地的距離和摧毀目標的概率見下表
工廠 距離/千米 摧毀目標概率(重型/中型)
1 450 0.10 0.08
2 480 0.20 0.16
3 540 0.15 0.12
4 600 0.25 0.20
所以應該去2號工廠1駕重型和1駕中型機,去4號工廠45駕重型機和31駕中型機。
『柒』 使用python解決提到數學題
先設s=25x+20y+60z
再隨便設y=0,z=0.得到x<=60.
這說明解中的x的范圍在[0,60]內.
之後就是在[0,60]范圍內尋找這個解的過程了
簡單的可以讓x取遍從0到60這61個數,找出其中最大的就行了
y的值也做同樣遍歷.z只取最大的就可以了
max, maxy = 0, 0
for x in range(61):
maxy = 200 - x
if maxy > (180 - 3 * x):
maxy = 180 - 3 * x
for y in range(maxy + 1):
z = 200 - x - 2 * y
if z > (180 - 3 * x - y):
z = (180 - 3 * x - y)
if max < (25 * x + 20 * y + 60 * z):
max = (25 * x + 20 * y + 60 * z)
print "x = %d, y = %d, z = %d, max = %d" %(x, y, z, max)
好久沒寫python了..語法都是剛剛查的.可能有錯誤哈.效率看起來也不高
『捌』 Python scipy庫線性規劃如何讓變數取整數
scipy做線性規劃不是很方便,推薦用pulp來做,這個模塊不屬於python的內置模塊,需要先安裝,pip install pulp
from pulp import *
# 設置對象
prob = LpProblem('myProblem', LpMinimize)
# 設置三個變數,並設置變數最小取值
x1 = LpVariable('x1', 0)
x2 = LpVariable('x2', 0)
x3 = LpVariable('x3', 0)
x4 = LpVariable('x4')
# 載入目標函數,默認是求最小值,因此這次對原目標函數乘以-1
prob += 3*x1 - 4*x2 + 2*x3 -5*x4
# 載入約束變數
prob += 4*x1 - x2 + 2*x3 -x4 == -2
prob += x1 + x2 -x3 + 2*x4 <= 14
prob += -2*x1 + 3*x2 + x3 -x4 >= 2
# 求解
『玖』 Python裡面的scipy庫如何計算線性規劃問題呢
這里有一篇文章介紹了如何做,但是不是你的例子,你參考以下,應該很簡單就能寫出來了http://jingyan..com/article/e2284b2b5800e6e2e6118d97.html