minizinc

class CostScaler(cost_values: List[float], significant_digits: int)[source]

Bases: object

Serves to scale floats and converts them into integers (and vice versa) whilst maintaining decimal precision

__init__(cost_values: List[float], significant_digits: int)
Parameters
  • cost_values – the sequence of cost values whose precision should be maintained in the int realm

  • significant_digits – the number of significant digits that shall at least be maintained

scaled_int(original_value: float) int

Returns the scaled value as an integer

scaled_float(original_value: float) float
original_value(scaled_value: float) float

Returns the original unscaled value from a scaled value

class MiniZincProblem[source]

Bases: abc.ABC

create_mini_zinc_file(f)

Writes MiniZinc code

Parameters

f – an OS-level handle to an open file

abstract get_mini_zinc_code()
class MiniZincSolver(name='OSICBC', solver_time_seconds=None, fzn_output_path=None)[source]

Bases: object

__init__(name='OSICBC', solver_time_seconds=None, fzn_output_path=None)
Parameters
  • name – name of solver compatible with miniZinc

  • solver_time_seconds – upper time limit for solver in seconds

  • fzn_output_path – flatZinc output path

solve_path(mzn_path: str, log_info=True) str

Solves the MiniZinc problem stored at the given file path

Parameters
  • mzn_path – path to file containing MiniZinc problem code

  • log_info – whether to log solver output at INFO level rather than DEBUG level

Returns

the solver output

solve_problem(problem: sensai.minizinc.MiniZincProblem, keep_temp_file=False, log_info=True) str

Solves the given MiniZinc problem

Parameters
  • problem – the problem to solve

  • keep_temp_file – whether to keep the temporary .mzv file

  • log_info – whether to log solver output at INFO level rather than DEBUG level

Returns

the solver output

get_last_solver_time_secs()
extract_1d_array_from_output(string_identifier: str, output: str) List[source]
extract_multi_dim_array_from_output(string_identifier: str, dim: int, output: str, boolean=False) numpy.array[source]
array_to_mini_zinc(a: numpy.array, element_cast)[source]