opt.single_objective.comb.min_set_cover_problem package

Submodules

opt.single_objective.comb.min_set_cover_problem.min_set_cover_problem module

class opt.single_objective.comb.min_set_cover_problem.min_set_cover_problem.MinSetCoverProblem(universe: Set[int], subsets: list[Set[int]])

Bases: Problem

Class representing the Minimum Set Cover Problem.

This class inherits from the TargetProblem class and is used to define and solve the Set Covering Problem Problem. The problem is defined by a set U and a list of subsets of U named S.

universe

set of elements U that should be covered.

Type:

Set[int]

subsets

list of subsets. Each subset covers some of the elements form U.

Type:

list[Set[int]]

__init__(universe

Set[int], subsets: list[Set[int]]): Initializes a new instance of the MinSetCoverProblem class.

__load_from_files__(universe_file_path

str, subsets_file_path: str) -> tuple: Static function that reads problem data from files.

from_input_files(universe_file_path

str, subsets_file_path: str): Creates a new MinSetCoverProblem instance when the input file and input format are specified.

__copy__() MinSetCoverProblem

Internal copy of the MinSetCoverProblem problem.

copy() MinSetCoverProblem

Copy the MinSetCoverProblem problem.

universe() Set[int]

Property getter for the set that should be covered in the target problem.

subsets() list[Set[int]]

Property getter for the list of subsets S of the target problem.

dimension() int

Property getter for the dimension of the target problem.

string_rep(delimiter

str, indentation: int = 0, indentation_symbol: str = ‘’, group_start: str = ‘{’, group_end: str = ‘}’) -> str: String representation of the MinSetCoverProblem instance.

__str__() str

String representation of the MinSetCoverProblem structure.

__repr__() str

Representation of the MinSetCoverProblem instance.

__format__() str

Formatted MinSetCoverProblem instance.

copy() MinSetCoverProblem

Copy the MinSetCoverProblem problem

Returns:

new MinSetCoverProblem instance with the same properties

Return type:

MinSetCoverProblem

property dimension: int

Property getter for dimension of the target problem

Returns:

dimension of the target problem instance

Return type:

int

classmethod from_input_files(universe_file_path: str, subsets_file_path: str) MinSetCoverProblem

Additional constructor. Create new MinSetCoverProblem instance when input file and input format are specified

Parameters:
  • universe_file_path (str) – path to the file that contains elements of the set U

  • subsets_file_path (str) – path to the file that contains list of subsets and their elements

Returns:

class instance

Return type:

MinMultiCutProblem

classmethod from_universe_and_subset_files(universe: Set[int], subsets: list)

Additional constructor. Create new MinSetCoverProblem instance where the universe and subsets are specified.

Parameters:
  • universe (Set[int]) – initial set U that should be covered in the problem

  • subsets (list[Set[int]]) – list of subsets S that should cover U in the problem

string_rep(delimiter: str, indentation: int = 0, indentation_symbol: str = '', group_start: str = '{', group_end: str = '}') str

String representation of the MinSetCoverProblem instance

Parameters:
  • delimiter (str) – delimiter between fields

  • indentation (int, optional, default value 0) – level of indentation

  • indentation_symbol (str, optional, default value '') – indentation symbol

  • group_start (str, optional, default value '{') – group start string

  • group_end (str, optional, default value '}') – group end string

Returns:

string representation of instance that controls output

Return type:

str

property subsets: list[Set[int]]

Property getter for the list of subsets S of the target problem

Returns:

list of subsets S of the target problem instance

Return type:

list

property universe: Set[int]

Property getter for the initial set U of the target problem

Returns:

set U of the target problem instance

Return type:

Set[int]

opt.single_objective.comb.min_set_cover_problem.min_set_cover_problem_bit_array_solution module

The set_covering_problem_bit_array_solution contains class MinSetCoverProblemBitArraySolution, that represents solution of the Minimum Set Cover Problem, where BitArray representation of the problem has been used.

class opt.single_objective.comb.min_set_cover_problem.min_set_cover_problem_bit_array_solution.MinSetCoverProblemBitArraySolution(random_seed: int | None = None, evaluation_cache_is_used: bool = False, evaluation_cache_max_size: int = 0, distance_calculation_cache_is_used: bool = False, distance_calculation_cache_max_size: int = 0)

Bases: Solution[BitArray, str]

argument(representation: BitArray) str

Argument of the target solution

Parameters:

representation (BitArray) – internal representation of the solution

Returns:

solution code

Return type:

str

calc_fitness(representation: BitArray, universe: set[int], subsets: list[set[int]]) tuple[bool, float]
calculate_quality_directly(representation: BitArray, problem: MinSetCoverProblem) QualityOfSolution

Fitness calculation of the set covering binary BitArray solution

Parameters:
  • representation (BitArray) – native representation of solution whose fitness is calculated

  • problem (Problem) – problem that is solved

Returns:

objective value, fitness value and feasibility of the solution instance

Return type:

QualityOfSolution

copy() MinSetCoverProblemBitArraySolution

Copy the MinSetCoverProblemBitArraySolution

Returns:

new MinSetCoverProblemBitArraySolution instance with the same properties

Return type:

MinSetCoverProblemBitArraySolution

copy_from(original) None

Copy all data from the original target solution

init_from(representation: BitArray, problem: Problem) None

Initialization of the solution, by setting its native representation

Parameters:
  • representation (BitArray) – representation that will be ste to solution

  • problem (Problem) – problem which is solved by solution

init_random(problem: Problem) None

Random initialization of the solution

Parameters:

problem (Problem) – problem which is solved by solution

is_feasible_sol(representation: BitArray, universe: set[int], subsets: list[set[int]]) bool
native_representation(representation_str: str) BitArray

Obtain BitArray representation from string representation of the BitArray binary solution of the Set Covering Problem

Parameters:

representation_str (str) – solution’s representation as string

Returns:

solution’s representation as BitArray

Return type:

BitArray

representation_distance_directly(solution_code_1: str, solution_code_2: str) float

Calculating distance between two solutions determined by its code

Parameters:
  • solution_code_1 (str) – solution code for the first solution

  • solution_code_2 (str) – solution code for the second solution

Returns:

distance between two solutions represented by its code

Return type:

float

string_rep(delimiter: str = '\n', indentation: int = 0, indentation_symbol: str = '   ', group_start: str = '{', group_end: str = '}') str

String representation of the solution instance

Parameters:
  • delimiter (str) – delimiter between fields

  • indentation (int, optional, default value 0) – level of indentation

  • indentation_symbol (str, optional, default value '') – indentation symbol

  • group_start (str, optional, default value '{') – group start string

  • group_end (str, optional, default value '}') – group end string

Returns:

string representation of instance that controls output

Return type:

str

opt.single_objective.comb.min_set_cover_problem.min_set_cover_problem_bit_array_solution.random() x in the interval [0, 1).

opt.single_objective.comb.min_set_cover_problem.min_set_cover_problem_ilp_linopy module

class opt.single_objective.comb.min_set_cover_problem.min_set_cover_problem_ilp_linopy.MinSetCoverProblemIntegerLinearProgrammingSolution(sol: MinSetCoverProblemIntegerLinearProgrammingSolver)

Bases: SolutionVoidObject

string_representation()

String representation of the target solution

Parameters:

representation (R_co) – internal representation of the solution

Returns:

string representation of the solution

Return type:

str

class opt.single_objective.comb.min_set_cover_problem.min_set_cover_problem_ilp_linopy.MinSetCoverProblemIntegerLinearProgrammingSolver(output_control: OutputControl = None, problem: MinSetCoverProblem = None)

Bases: Optimizer

copy()

Copy the current algorithm

Returns:

new MinSetCoverProblemIntegerLinearProgrammingSolver instance with the same properties

Return type:

:class:MinSetCoverProblemIntegerLinearProgrammingSolver

classmethod from_construction_tuple(construction_params: MinSetCoverProblemIntegerLinearProgrammingSolverConstructionParameters = None)

Additional constructor. Create new MinSetCoverProblemIntegerLinearProgrammingSolver instance from construction parameters

Parameters:

construction_params (MinSetCoverProblemIntegerLinearProgrammingSolverConstructionParameters) – parameters for construction

property model: Model

Property getter for the ILP model

Returns:

model of the problem

Return type:

Model

optimize() MinSetCoverProblemIntegerLinearProgrammingSolution

Uses ILP model in order to solve MinSetCoverProblem

string_rep(delimiter: str, indentation: int = 0, indentation_symbol: str = '', group_start: str = '{', group_end: str = '}') str

String representation of the ‘MinSetCoverProblemIntegerLinearProgrammingSolver’ instance

Parameters:
  • delimiter (str) – delimiter between fields

  • indentation (int, optional, default value 0) – level of indentation

  • indentation_symbol (str, optional, default value '') – indentation symbol

  • group_start (str, optional, default value '{') – group start string

  • group_end (str, optional, default value '}') – group end string

Returns:

string representation of instance that controls output

Return type:

str

class opt.single_objective.comb.min_set_cover_problem.min_set_cover_problem_ilp_linopy.MinSetCoverProblemIntegerLinearProgrammingSolverConstructionParameters(problem: Problem = None, output_control: OutputControl | None = None)

Bases: object

Instance of the class MinSetCoverProblemIntegerLinearProgrammingSolverConstructionParameters represents constructor parameters for set covering problem ILP solver.

property output_control: OutputControl

Property getter for the output control

Returns:

output control

Return type:

OutputControl

property problem: Problem

Property getter for the output control

Returns:

problem that is solved

Return type:

Problem

Module contents