91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 10KB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2021-05-28
  • 語言: Python
  • 標簽: python??cplex??

資源簡介

使用python調用cplex的兩個實例,適合初學者進行學習,語法清晰

資源截圖

代碼片段和文件信息

#!/usr/bin/env?python3
#?-*-?coding:?utf-8?-*-
“““
Created?on?Sat?Sep?23?08:39:49?2017

@author:?sheboke
“““

import?cplex
problem?=?cplex.Cplex()
problem.objective.set_sense(problem.objective.sense.minimize)
names?=?[‘a‘‘b‘‘c‘‘d‘‘e‘‘f‘‘g‘‘h‘]
objective?=[140.0100.080.09.013.015.08.0140.0]
lower_bounds=[0.00.00.00.00.00.00.00.0]
i=10
upper_bounds?=?[iiiiiiii]
problem.variables.add(obj?=?objective?
??????????????????????lb?=lower_bounds?
??????????????????????ub?=?upper_bounds?
??????????????????????names?=?names)
#將變量設置為整數
problem.variables.set_types([(‘a‘problem.variables.type.integer)
????????????????????????????(‘b‘problem.variables.type.integer)
????????????????????????????(‘c‘problem.variables.type.integer)
????????????????????????????(‘d‘problem.variables.type.integer)
????????????????????????????(‘e‘problem.variables.type.integer)
????????????????????????????(‘f‘problem.variables.type.integer)
????????????????????????????(‘g‘problem.variables.type.integer)
????????????????????????????(‘h‘problem.variables.type.integer)])
constraint_names=[‘c1‘‘c2‘?‘c3‘?‘c4‘?‘c5‘‘c6‘]
first_constraint?=?[[‘a‘‘b‘‘c‘‘d‘‘e‘‘f‘?‘g‘‘h‘][5.06.05.00.50.70.10.13.0]]
second_constraint?=?[[0?1?2?3?4?5?6?7][3.05.02.00.50.20.10.25.0]]
third_constraint?=?[[0?1?2?3?4?5?6?7][1.03.00.00.30.00.30.04.0]]
fouth_constraint?=?[[0?1?2?3?4?5?6?7][6.01.04.00.10.90.60.13.0]]
fifth_constraint?=?[[0?1?2?3?4?5?6?7][4.01.02.00.10.11.30.25.0]]
sixth_constraint?=[[0?1?2?3?4?5?6?7][2.01.00.00.00.00.40.34.0]]
constraints?=?[first_constraint?second_constraintthird_constraintfouth_constraintfifth_constraintsixth_constraint]
rhs?=?[60.060.028.060.060.028.0]
#L是<=,G>=
constraint_senses?=[‘G‘‘G‘‘G‘‘G‘‘G‘‘G‘]
problem.linear_constraints.add(lin_expr?=?constraints?
??????????????????????????????senses?=?constraint_senses
??????????????????????????????rhs?=?rhs
??????????????????????????????names?=?constraint_names)
#將integer?optimal設置為1%
problem.parameters.mip.tolerances.mipgap.set(0.01)
problem.solve()
print(problem.solution.get_objective_value())
print(problem.solution.get_values())

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????88585??2017-10-31?11:03??Cplex-master\Cplex.ipynb
?????文件?????????263??2017-10-31?11:03??Cplex-master\README.md
?????文件????????2256??2017-10-31?11:03??Cplex-master\cplex1.py
?????文件????????2509??2017-10-31?11:03??Cplex-master\cplex2.py
?????目錄???????????0??2018-06-04?19:49??Cplex-master\

評論

共有 條評論