allagash.problem module

Problem

class allagash.problem.Problem(pulp_problem, coverages, problem_type)

A representation of the linear programming problem that can be solved. This is not intended to be created on it’s own but rather from one of the factory methods lscp() or mclp()

Problem.lscp(coverage)
Problem.lscp([coverage1, coverage2])
Parameters:
  • pulp_problem (LpProblem) – The pulp problem that will be solved

  • coverages (list[Coverage]) – The coverages that were used to build the problem

  • problem_type (str) – The type of problem that was generated

classmethod bclp(coverages, max_supply)

Creates a new Problem object representing the Backup Covering Location Problem

Parameters:
  • coverages (list[Coverage]) – The coverages to be used to create the problem

  • max_supply (dict[Coverage,int]) – The maximum number of supply locations to allow

Returns:

The created problem

Return type:

Problem

property coverages
Returns:

The coverage used to create the problem

Return type:

list[Coverage]

classmethod lscp(coverages)

Creates a new Problem object representing the Location Covering Set Problem

Parameters:

coverages (list[Coverage]) – The coverages to be used to create the problem

Returns:

The created problem

Return type:

Problem

classmethod mclp(coverages, max_supply)

Creates a new Problem object representing the Maximum Covering Location Problem

Parameters:
  • coverages (list[Coverage]) – The coverages to be used to create the problem

  • max_supply (dict[Coverage,int]) – The maximum number of supply locations to allow

Returns:

The created problem

Return type:

Problem

property problem_type
Returns:

The type of problem that this is

Return type:

str

property pulp_problem
Returns:

The pulp problem

Return type:

LpProblem

selected_demand(coverage)

Gets the list of the demand locations that were selected when the optimization problem was solved.

Parameters:

coverage (Coverage) – The coverage that the demand locations may be found in. If multiple coverages were used that have the same demand, locations covered by any other coverages will also be returned.

Returns:

The list of location ids of the covered locations

Return type:

list

selected_supply(coverage, operation=<built-in function eq>, value=1)

Gets the list of the supply locations that were selected when the optimization problem was solved.

Parameters:
  • coverage (Coverage) – The coverage that selected locations may be found in.

  • operation (function) – The operation to use when determining whether a location was selected

  • value (int) – The value to apply the operation to

Returns:

The list of location ids of the selected locations

Return type:

list

solve(solver)
Parameters:

solver (LpSolver) – The solver to use for this problem

Returns:

The solution for this problem

Return type:

Problem

InfeasibleException

class allagash.problem.NotSolvedException(message)

An exception indicating the problem was not solved

Parameters:

message (str) – A descriptive message about the exception

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

NotSolvedException

class allagash.problem.InfeasibleException(message)

An exception indicating the problem as an infeasible solution

Parameters:

message (str) – A descriptive message about the exception

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

UnboundedException

class allagash.problem.UnboundedException(message)

An exception indicating the solution is unbounded

Parameters:

message (str) – A descriptive message about the exception

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

UndefinedException

class allagash.problem.UndefinedException(message)

An exception indicating the problem was not solved for an undefined reason

Parameters:

message (str) – A descriptive message about the exception

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.