当前位置: 首页 > news >正文

西安广告设计与制作公司济南seo快速霸屏

西安广告设计与制作公司,济南seo快速霸屏,东莞做个网站,建设网站哪家好python虽然不是完全为数学建模而生的,但是它完整的库让它越来越适合建模了。 - 线性规划:使用scipy.optimize.linprog()函数 python from scipy.optimize import linprogc [-1, 4] A [[-3, 1], [1, 2]] b [6, 4] x0_bounds (None, None) x1_bound…

python虽然不是完全为数学建模而生的,但是它完整的库让它越来越适合建模了。

- 线性规划:使用scipy.optimize.linprog()函数
 

```python
from scipy.optimize import linprogc = [-1, 4]
A = [[-3, 1], [1, 2]]
b = [6, 4]
x0_bounds = (None, None)
x1_bounds = (-3, None)
res = linprog(c, A_ub=A, b_ub=b, bounds=[x0_bounds, x1_bounds], method='highs')
print(res)
```



- 整数规划:使用scipy.optimize.linprog()函数,并将目标函数系数转换为整数
 

```python
from scipy.optimize import linprogc = [-1, 4]
A = [[-3, 1], [1, 2]]
b = [6, 4]
x0_bounds = (None, None)
x1_bounds = (-3, None)
res = linprog(c, A_ub=A, b_ub=b, bounds=[x0_bounds, x1_bounds], method='highs', integer=True)
print(res)
```



- 多元规划:使用scipy.optimize.linprog()函数
 

```python
from scipy.optimize import linprogc = [-1, 4]
A = [[-3, 1, 1], [1, 2, 3]]
b = [6, 4, 5]
x0_bounds = (None, None, None)
x1_bounds = (-3, -3, -3)
res = linprog(c, A_ub=A, b_ub=b, bounds=[x0_bounds, x1_bounds], method='highs')
print(res)
```



- 二次规划:使用scipy.optimize.linprog()函数,并将目标函数系数转换为平方项
 

```python
from scipy.optimize import linprogc = [-1, 4]
A = [[-3, 1], [1, 2]]
b = [6, 4]
x0_bounds = (None, None)
x1_bounds = (-3, None)
res = linprog(c, A_ub=A, b_ub=b, bounds=[x0_bounds, x1_bounds], method='highs', square_root=True)
print(res)
```



- 遗传算法:使用DEAP库
 

```python
from deap import base, creator, tools, algorithms
import randomcreator.create("FitnessMin", base.Fitness, weights=(-1.0,))
creator.create("Individual", list, fitness=creator.FitnessMin)toolbox = base.Toolbox()
toolbox.register("attr_bool", random.randint, 0, 1)
toolbox.register("individual", tools.initRepeat, creator.Individual, toolbox.attr_bool, n=100)
toolbox.register("population", tools.initRepeat, list, toolbox.individual)def evalOneMax(individual):return sum(individual),toolbox.register("evaluate", evalOneMax)
toolbox.register("mate", tools.cxTwoPoint)
toolbox.register("mutate", tools.mutFlipBit, indpb=0.05)
toolbox.register("select", tools.selTournament, tournsize=3)population = toolbox.population(n=300)
algorithms.eaSimple(population, toolbox, cxpb=0.5, mutpb=0.2, ngen=40)
```



- 动态规划:使用scipy.optimize.linprog()函数,并将目标函数转换为动态规划问题
 

```python
from scipy.optimize import linprogc = [-1, 4]
A = [[-3, 1], [1, 2]]
b = [6, 4]
x0_bounds = (None, None)
x1_bounds = (-3, None)
res = linprog(c, A_ub=A, b_ub=b, bounds=[x0_bounds, x1_bounds], method='highs')
print(res)
```



- 贪心算法:使用scipy.optimize.linprog()函数,并将目标函数转换为贪心策略
 

```python
from scipy.optimize import linprogc = [-1, 4]
A = [[-3, 1], [1, 2]]
b = [6, 4]
x0_bounds = (None, None)
x1_bounds = (-3, None)
res = linprog(c, A_ub=A, b_ub=b, bounds=[x0_bounds, x1_bounds], method='highs', options={'disp': True})
while not res.success:if not res.fun:print("Objective function value is 0 at point %s" % res.x)breakif res.status == 4:print("The algorithm could not find a feasible solution for the problem")breakprint(res)res = linprog(c, A_ub=A, b_ub=b, bounds=[x0_bounds, x1_bounds], method='highs', options={'disp': True})
print(res)
```

下次再更新一些高难度的常见算法。
 

http://www.ds6.com.cn/news/9710.html

相关文章:

  • wordpress怎么做企业网站企业文化标语
  • 企业做的网站推广费用如何记账深圳网站建设公司排名
  • 沈阳营销型网站制作百度账号人工客服
  • 顶部固定网站模板推广网站哪个好
  • 网软志成企业网站管理系统链爱交易平台
  • 给你一个网站你如何做优化网络营销与直播电商专升本
  • 百度排名优化软件泉州seo技术
  • 南京百度网站快速优化seo赚钱培训
  • 广州网站建设外包刚刚地震最新消息今天
  • 网站建设学习樱桃磁力bt天堂
  • 1+x数字营销网站新网站seo
  • 竭诚网络网站建设营销型网站建设实训总结
  • 个人网站搭建详细流程移动排名提升软件
  • 做移动端网站设计线上推广的优势和好处
  • 团建网站长沙优化科技有限公司正规吗
  • 做网站需要哪一些内容哈尔滨seo优化软件
  • 佛山网站建设网站制作公司哪家好抚州网站seo
  • 坪山网站建设基本流程app开发公司
  • 网站后台无法访问seo怎么做最佳
  • 深圳南山做网站免费建站系统官网
  • 免费申请网站永久域名设计网站模板
  • 乐清微网站建设优化的近义词
  • 电商网站怎么做权限控制怎么自己刷推广链接
  • 做西班牙语网站旺道seo
  • 做网站实训心得杭州网站建设技术支持
  • 做智能家居网站需要的参考文献南京网站制作设计
  • 静态网站维护网站搭建费用
  • 网站banner轮播代码百度指数首页
  • wordpress建站速度提升网络推广公司网站
  • 东莞多地调整为中高风险地区天津seo网络营销