opt.single_objective.glob.max_function_one_variable_problem package

Submodules

opt.single_objective.glob.max_function_one_variable_problem.command_line module

The command_line module is used for obtaining execution parameters for execution of the optimizers for max ones problem.

opt.single_objective.glob.max_function_one_variable_problem.command_line.parse_arguments()

The parse_arguments function parses execution parameters for execution of the optimizers for max ones problem.

opt.single_objective.glob.max_function_one_variable_problem.max_function_one_variable_problem module

class opt.single_objective.glob.max_function_one_variable_problem.max_function_one_variable_problem.MaxFunctionOneVariableMaxProblem(expression: str, domain_low: float, domain_high: float)

Bases: Problem

copy()

Copy the current target problem

Returns:

new Problem instance with the same properties

Return type:

Problem

property domain_high: float
property domain_low: float
property expression: str
classmethod from_input_file(input_file_path: str, input_format: str)

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

Parameters:
  • input_file_path (str) – path of the input file with problem data

  • input_format (str) – format of the input

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

String representation of the target problem 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.glob.max_function_one_variable_problem.max_function_one_variable_problem.MaxFunctionOneVariableMaxProblemElements(expression, domain_low, domain_high)

Bases: tuple

domain_high: float

Alias for field number 2

domain_low: float

Alias for field number 1

expression: str

Alias for field number 0

opt.single_objective.glob.max_function_one_variable_problem.max_function_one_variable_problem_bit_array_solution module

class opt.single_objective.glob.max_function_one_variable_problem.max_function_one_variable_problem_bit_array_solution.FunctionOneVariableMaxProblemBitArraySolution(domain_from: float, domain_to: float, number_of_intervals: int, random_seed: int = 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, float]

argument(representation: BitArray) float

Argument of the target solution

Parameters:

representation (R_co) – internal representation of the solution

Returns:

argument of the solution

Return type:

A_co

property bit_array_len: int
calculate_quality_directly(representation: int, problem: MaxFunctionOneVariableMaxProblem) QualityOfSolution

Fitness calculation of the target solution

Parameters:
  • representation (R_co) – native representation of the solution for which objective value, fitness and feasibility are calculated

  • problem (Problem) – problem that is solved

Returns:

objective value, fitness value and feasibility of the solution instance

Return type:

QualityOfSolution

copy()

Copy the current target solution

Returns:

new uo.solution.Solution instance with the same properties

Return type:

Solution

property domain_from: float
property domain_to: float
init_from(representation: BitArray, problem: MaxFunctionOneVariableMaxProblem) None

Initialization of the solution, by setting its native representation

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

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

init_random(problem: MaxFunctionOneVariableMaxProblem) None

Random initialization of the solution

Parameters:

problem (Problem) – problem which is solved by solution

native_representation(representation_str: str) BitArray

Obtain native representation from solution code of the Solution instance

Parameters:

representation_str (str) – solution’s representation as string (e.g. solution code)

Returns:

solution’s native representation

Return type:

R_co

property number_of_intervals: int
obtain_feasible_representation(problem: MaxFunctionOneVariableMaxProblem) BitArray
representation_distance_directly(solution_code_1: str, solution_code_2: str) float

Calculates the distance between two binary representations of solutions.

Parameters:
  • solution_code_1 (str) – The binary representation of the first solution.

  • solution_code_2 (str) – The binary representation of the second solution.

Returns:

The representation distance between the two binary solutions.

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 target 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.glob.max_function_one_variable_problem.max_function_one_variable_problem_bit_array_solution.random() x in the interval [0, 1).

opt.single_objective.glob.max_function_one_variable_problem.max_function_one_variable_problem_int_solution module

class opt.single_objective.glob.max_function_one_variable_problem.max_function_one_variable_problem_int_solution.FunctionOneVariableMaxProblemIntSolution(domain_from: float, domain_to: float, number_of_intervals: int, random_seed: int = 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[int, float]

argument(representation: int) float

Argument of the target solution

Parameters:

representation (R_co) – internal representation of the solution

Returns:

argument of the solution

Return type:

A_co

calculate_quality_directly(representation: int, problem: MaxFunctionOneVariableMaxProblem) QualityOfSolution

Fitness calculation of the target solution

Parameters:
  • representation (R_co) – native representation of the solution for which objective value, fitness and feasibility are calculated

  • problem (Problem) – problem that is solved

Returns:

objective value, fitness value and feasibility of the solution instance

Return type:

QualityOfSolution

copy()

Copy the current target solution

Returns:

new uo.solution.Solution instance with the same properties

Return type:

Solution

property domain_from: float
property domain_to: float
init_from(representation: int, problem: MaxFunctionOneVariableMaxProblem) None

Initialization of the solution, by setting its native representation

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

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

init_random(problem: MaxFunctionOneVariableMaxProblem) None

Random initialization of the solution

Parameters:

problem (Problem) – problem which is solved by solution

native_representation(representation_str: str) int

Obtain native representation from solution code of the Solution instance

Parameters:

representation_str (str) – solution’s representation as string (e.g. solution code)

Returns:

solution’s native representation

Return type:

R_co

property number_of_intervals: int
obtain_feasible_representation(problem: MaxFunctionOneVariableMaxProblem)
representation_distance_directly(solution_code_1: str, solution_code_2: str) float

Calculates the distance between two binary representations of solutions.

Parameters:
  • solution_code_1 (str) – The binary representation of the first solution.

  • solution_code_2 (str) – The binary representation of the second solution.

Returns:

The representation distance between the two binary solutions.

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 target 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.glob.max_function_one_variable_problem.max_function_one_variable_problem_int_solution.random() x in the interval [0, 1).

opt.single_objective.glob.max_function_one_variable_problem.solver module

The opt.single_objective.comb.ones_count_max_problem.solver contains programming code that optimize Max Ones Problem with various optimization techniques.

opt.single_objective.glob.max_function_one_variable_problem.solver.main()

This function executes solver.

Which solver will be executed depends of command-line parameter algorithm.

opt.single_objective.glob.max_function_one_variable_problem.solver.random() x in the interval [0, 1).

Module contents