本文整理汇总了Python中pulp.LpStatus方法的典型用法代码示例。如果您正苦于以下问题:Python pulp.LpStatus方法的具体用法?Python pulp.LpStatus怎么用?Python pulp.LpStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pulp
的用法示例。
在下文中一共展示了pulp.LpStatus方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _print_for_one_dmu
# 需要导入模块: import pulp [as 别名]
# 或者: from pulp import LpStatus [as 别名]
def _print_for_one_dmu(self, dmu_code):
''' Prints on screen all information available for a given DMU.
Args:
dmu_code (str): DMU code.
'''
print('DMU: {dmu}'.format(
dmu=self._input_data.get_dmu_user_name(dmu_code)))
print('code: ', dmu_code)
if self.lp_status.get(dmu_code):
print('LP status: {status}'.format(
status=LpStatus[self.lp_status.get(dmu_code)]))
if self.lp_status.get(dmu_code) == LpStatusOptimal:
print('Efficiency score: {score}'.format(
score=self.efficiency_scores.get(dmu_code)))
print('Lambda variables: {vars}'.format(
vars=self.get_lambda_variables(dmu_code)))
print('Input duals: {duals}'.format(
duals=self.input_duals.get(dmu_code)))
print('Output duals: {duals}'.format(
duals=self.output_duals.get(dmu_code)))
示例2: solve
# 需要导入模块: import pulp [as 别名]
# 或者: from pulp import LpStatus [as 别名]
def solve(self):
super(_LP, self).solve()
objective = pulp.value(self.objective)
variables, values = [], []
for v in self.variables():
variables.append(v.name)
values.append(v.varValue)
status = pulp.LpStatus[self.status]
self.assignVarsVals(dict.fromkeys(variables, None))
return Result(status_code=self.status,
status=status,
objective=objective,
variables=variables,
values=values)
# =============================================================================
# CONCRETE CLASS
# =============================================================================
示例3: label_prop
# 需要导入模块: import pulp [as 别名]
# 或者: from pulp import LpStatus [as 别名]
def label_prop(C, nt, Dct, lp="linear"):
#Inputs:
# C : Number of share classes between src and tar
# nt : Number of target domain samples
# Dct : All d_ct in matrix form, nt * C
# lp : Type of linear programming: linear (default) | binary
#Outputs:
# Mcj : all M_ct in matrix form, m * C
Dct = abs(Dct)
model = pulp.LpProblem("Cost minimising problem", pulp.LpMinimize)
Mcj = pulp.LpVariable.dicts("Probability",
((i, j) for i in range(C) for j in range(nt)),
lowBound=0,
upBound=1,
cat='Continuous')
# Objective Function
model += (
pulp.lpSum([Dct[j, i]*Mcj[(i, j)] for i in range(C) for j in range(nt)])
)
# Constraints
for j in range(nt):
model += pulp.lpSum([Mcj[(i, j)] for i in range(C)]) == 1
for i in range(C):
model += pulp.lpSum([Mcj[(i, j)] for j in range(nt)]) >= 1
# Solve our problem
model.solve()
pulp.LpStatus[model.status]
Output = [[Mcj[i, j].varValue for i in range(C)] for j in range(nt)]
return np.array(Output)
示例4: add_lp_status
# 需要导入模块: import pulp [as 别名]
# 或者: from pulp import LpStatus [as 别名]
def add_lp_status(self, dmu_code, lp_status):
''' Adds LP status corresponding to a given DMU to internal
data structure.
Args:
dmu_code (str): DMU code.
lp_status (pulp.LpStatus): LP status.
'''
self._check_if_dmu_code_exists(dmu_code)
self.lp_status[dmu_code] = lp_status
示例5: create_sheet_onion_rank
# 需要导入模块: import pulp [as 别名]
# 或者: from pulp import LpStatus [as 别名]
def create_sheet_onion_rank(self, work_sheet, solution, start_row_index,
params_str):
''' Writes information about peel the onion solution to a given output.
Args:
work_sheet: object that has name attribute and implements
write method, it actually writes data to some output
(like file, screen, etc.).
solution (Solution): solution.
start_row_index (int): initial row index (usually used to append
data to existing output).
params_str (str): string that is usually written in the first
row.
Returns:
int: index of the last row where data were written plus 1.
'''
work_sheet.name = 'OnionRank'
# in case of max_slacks and peel-the-onion we should not
# write ranks twice
if self.count < len(self.ranks):
work_sheet.write(start_row_index, 0, params_str)
work_sheet.write(
start_row_index + 1, 0,
'Tier / Rank is the run in which DMU became efficient')
work_sheet.write(start_row_index + 2, 0, 'DMU')
work_sheet.write(start_row_index + 2, 1, 'Efficiency')
work_sheet.write(start_row_index + 2, 2, 'Tier / Rank')
ordered_dmu_codes = solution._input_data.DMU_codes_in_added_order
row_index = start_row_index + 3
for dmu_code in ordered_dmu_codes:
work_sheet.write(
row_index, 0,
solution._input_data.get_dmu_user_name(dmu_code))
if solution.lp_status[dmu_code] == pulp.LpStatusOptimal:
work_sheet.write(row_index, 1,
solution.get_efficiency_score(dmu_code))
work_sheet.write(row_index, 2,
self.ranks[self.count][dmu_code])
else:
work_sheet.write(
row_index, 1,
pulp.LpStatus[solution.lp_status[dmu_code]])
row_index += 1
self.count += 1
return row_index
return -1
示例6: create_sheet_efficiency_scores
# 需要导入模块: import pulp [as 别名]
# 或者: from pulp import LpStatus [as 别名]
def create_sheet_efficiency_scores(self, work_sheet, solution,
start_row_index, params_str):
''' Writes efficiency scores to a given output.
Args:
work_sheet: object that has name attribute and implements
write method, it actually writes data to some output
(like file, screen, etc.).
solution (Solution): solution.
start_row_index (int): initial row index (usually used to append
data to existing output).
params_str (str): string that is usually written in the first
row.
Returns:
int: index of the last row where data were written plus 1.
'''
work_sheet.name = 'EfficiencyScores'
work_sheet.write(start_row_index, 0, params_str)
work_sheet.write(start_row_index + 1, 0, 'DMU')
work_sheet.write(start_row_index + 1, 1, 'Efficiency')
if self.categorical is not None:
work_sheet.write(start_row_index + 1, 2,
'Categorical: {0}'.format(self.categorical))
ordered_dmu_codes = solution._input_data.DMU_codes_in_added_order
row_index = 0
for count, dmu_code in enumerate(ordered_dmu_codes):
row_index = start_row_index + count + 2
work_sheet.write(
row_index, 0, solution._input_data.get_dmu_user_name(dmu_code))
if solution.lp_status[dmu_code] == pulp.LpStatusOptimal:
work_sheet.write(
row_index, 1, solution.get_efficiency_score(dmu_code))
else:
work_sheet.write(
row_index, 1, pulp.LpStatus[solution.lp_status[dmu_code]])
if self.categorical is not None:
work_sheet.write(
row_index, 2,
int(solution._input_data.coefficients[
dmu_code, self.categorical]))
return row_index
示例7: create_sheet_peers
# 需要导入模块: import pulp [as 别名]
# 或者: from pulp import LpStatus [as 别名]
def create_sheet_peers(work_sheet, solution, start_row_index, params_str):
''' Writes peers to a given output.
Args:
work_sheet: object that has name attribute and implements
write method, it actually writes data to some output
(like file, screen, etc.).
solution (Solution): solution.
start_row_index (int): initial row index (usually used to append
data to existing output).
params_str (str): string that is usually written in the first
row.
Returns:
int: index of the last row where data were written plus 1.
'''
work_sheet.name = 'Peers'
work_sheet.write(start_row_index, 0, params_str)
work_sheet.write(start_row_index + 1, 0, 'DMU')
work_sheet.write(start_row_index + 1, 2, 'Peer')
work_sheet.write(start_row_index + 1, 3, 'Lambda')
write_classification = False
if bool(solution.return_to_scale):
work_sheet.write(start_row_index + 1, 4, 'Classification')
write_classification = True
ordered_dmu_codes = solution._input_data.DMU_codes_in_added_order
row_index = start_row_index + 2
for dmu_code in ordered_dmu_codes:
work_sheet.write(row_index, 0, solution._input_data.get_dmu_user_name(
dmu_code))
if solution.lp_status[dmu_code] == pulp.LpStatusOptimal:
lambda_vars = solution.get_lambda_variables(dmu_code)
# sum_of_lambda_values = 0
once = True
# for dmu, lambda_value in lambda_vars.items():
# if lambda_value:
# sum_of_lambda_values += lambda_value
for dmu, lambda_value in lambda_vars.items():
if lambda_value:
dmu_name = solution._input_data.get_dmu_user_name(dmu)
work_sheet.write(row_index, 2, dmu_name)
work_sheet.write(row_index, 3, lambda_value)
if write_classification and once:
work_sheet.write(
row_index, 4, solution.return_to_scale[dmu_code]
#_calculate_frontier_classification(sum_of_lambda_values)
)
once = False
row_index += 1
else:
work_sheet.write(
row_index, 2, pulp.LpStatus[solution.lp_status[dmu_code]])
row_index += 1
return row_index