This page is for an old version of Hexaly Optimizer. We recommend that you update your version and read the documentation for the latest stable release.

LSStatistics Class

class localsolver.LSStatistics

Statistics of the search. The statistics are useful for evaluating the quality of your model. Indeed, your model is suited for LocalSolver (and more generally for local search) if the percentage of accepted moves is larger than 1 % with an annealing level equal to 0. Larger is the percentage of accepted moves, larger is the diversification of the search, better is the convergence toward high-quality solutions. If the number of accepted moves is too low, we suggests you to relax some constraints of the model (goal programming) or to augment the annealing level. A fine modeling is much preferable to a fine tuning of the search, both for effectiveness and for robustness.

Summary

Methods
get_running_time Gets the running time in seconds.
get_nb_iterations Gets the number of iterations.
get_nb_moves Gets the number of (attempted) moves.
get_nb_accepted_moves Gets the number of accepted moves.
get_nb_improving_moves Gets the number of accepted moves having improved the cost of the current solution.
get_nb_rejected_moves Gets the number of rejected moves.
get_nb_infeasible_moves Gets the number of moves leading to infeasible solutions.
get_percent_accepted_moves Gives the percentage of accepted moves relative to the number of moves.
get_percent_improving_moves Gives the percentage of improving moves relative to the number of moves.
get_percent_rejected_moves Gives the percentage of rejected moves relative to the number of moves.
get_percent_infeasible_moves Gives the percentage of infeasible moves relative to the number of moves.
get_info Returns useful info about the search while running.
Attributes
running_time Running time in seconds.
nb_iterations Number of iterations.
nb_moves Number of attempted moves.
nb_accepted_moves Number of accepted moves.
nb_improving_moves Number of improving moves.
nb_rejected_moves Number of rejected moves.
nb_infeasible_moves Number of infeasible moves.
percent_accepted_moves Percentage of accepted moves relative to the number of moves.
percent_improving_moves Percentage of improving moves relative to the number of moves.
percent_rejected_moves Percentage of rejected moves relative to the number of moves.
percent_infeasible_moves Percentage of infeasible moves relative to the number of moves.
info Useful info about the search.
Special methods
__str__ Returns a string representation of the statistics.

Instance methods

LSStatistics.get_running_time()

Gets the running time in seconds. Note that is the “real” time spent (and not only the CPU or system time). Only allowed in states LSState.PAUSED or LSState.STOPPED.

You can also use the shortcut member running_time

Returns:Running time in seconds
Return type:int
LSStatistics.get_nb_iterations()

Gets the number of iterations. Only allowed in states LSState.PAUSED or LSState.STOPPED.

You can also use the shortcut member nb_iterations

Returns:Number of iterations.
Return type:int
LSStatistics.get_nb_moves()

Gets the number of (attempted) moves. This corresponds to the number of explored solutions (feasible or infeasible). Only allowed in states LSState.PAUSED or LSState.STOPPED.

You can also use the shortcut member nb_moves

Returns:Number of (attempted) moves.
Return type:int
LSStatistics.get_nb_accepted_moves()

Gets the number of accepted moves. Only allowed in states LSState.PAUSED or LSState.STOPPED.

You can also use the shortcut member nb_accepted_moves

Returns:Number of accepted moves.
Return type:int
LSStatistics.get_nb_improving_moves()

Gets the number of accepted moves having improved the cost of the current solution. Improving moves are a part of accepted moves. Only allowed in states LSState.PAUSED or LSState.STOPPED.

Returns:Number of improving moves.
Return type:int
LSStatistics.get_nb_rejected_moves()

Gets the number of rejected moves. Only allowed in states LSState.PAUSED or LSState.STOPPED.

You can also use the shortcut member nb_rejected_moves

Returns:Number of rejected moves.
Return type:int
LSStatistics.get_nb_infeasible_moves()

Gets the number of moves leading to infeasible solutions. Infeasible moves are a part of rejected moves. Only allowed in states LSState.PAUSED or LSState.STOPPED.

You can also use the shortcut member nb_infeasible_moves

Returns:Number of infeasible moves.
Return type:int
LSStatistics.get_percent_accepted_moves()

Gives the percentage of accepted moves relative to the number of moves. Only allowed in states LSState.PAUSED or LSState.STOPPED.

You can also use the shortcut member percent_accepted_moves

Returns:Percentage of accepted moves.
Return type:double
LSStatistics.get_percent_improving_moves()

Gives the percentage of improving moves relative to the number of moves. Only allowed in states LSState.PAUSED or LSState.STOPPED.

You can also use the shortcut member percent_improving_moves

Returns:Percentage of improving moves.
Return type:double
LSStatistics.get_percent_rejected_moves()

Gives the percentage of rejected moves relative to the number of moves. Only allowed in states LSState.PAUSED or LSState.STOPPED.

You can also use the shortcut member percent_rejected_moves

Returns:Percentage of rejected moves.
Return type:double
LSStatistics.get_percent_infeasible_moves()

Gives the percentage of infeasible moves relative to the number of moves. Only allowed in states LSState.PAUSED or LSState.STOPPED.

You can also use the shortcut member percent_infeasible_moves

Returns:Percentage of infeasible moves.
Return type:double
LSStatistics.get_info()

Returns useful info about the search while running. Only allowed if the solver has been started at least once. Only allowed in states LSState.PAUSED or LSState.STOPPED. Useful for debugging or logging purposes.

Here are some explanations about the output string:

  • “mov” corresponds to the number of moves performed.
  • “inf” corresponds to the percentage of infeasible moves.
  • “acc” corresponds to the percentage of accepted moves.
  • “imp” corresponds to the number of improving moves.
Returns:Info about the search while running.
Return type:str

Instance attributes

All get/set methods have their attribute counterpart. You can use them as shortcuts to improve the readability or your models and codes.

LSStatistics.running_time

Running time in seconds. This attribute is read-only. It is a shortcut for get_running_time().

LSStatistics.nb_iterations

Number of iterations. This attribute is read-only. It is a shortcut for get_nb_iterations().

LSStatistics.nb_moves

Number of attempted moves. This attribute is read-only. It is a shortcut for get_nb_moves().

LSStatistics.nb_accepted_moves

Number of accepted moves. This attribute is read-only. It is a shortcut for get_nb_accepted_moves().

LSStatistics.nb_improving_moves

Number of improving moves. This attribute is read-only. It is a shortcut for get_nb_improving_moves().

LSStatistics.nb_rejected_moves

Number of rejected moves. This attribute is read-only. It is a shortcut for get_nb_rejected_moves().

LSStatistics.nb_infeasible_moves

Number of infeasible moves. This attribute is read-only. It is a shortcut for get_nb_infeasible_moves().

LSStatistics.percent_accepted_moves

Percentage of accepted moves relative to the number of moves. This attribute is read-only. It is a shortcut for get_percent_accepted_moves().

LSStatistics.percent_improving_moves

Percentage of improving moves relative to the number of moves. This attribute is read-only. It is a shortcut for get_percent_improving_moves().

LSStatistics.percent_rejected_moves

Percentage of rejected moves relative to the number of moves. This attribute is read-only. It is a shortcut for get_percent_rejected_moves().

LSStatistics.percent_infeasible_moves

Percentage of infeasible moves relative to the number of moves. This attribute is read-only. It is a shortcut for get_percent_infeasible_moves().

LSStatistics.info

Useful info about the search. This attribute is read-only. It is a shortcut for get_info().

Special operators and methods

LSStatistics.__str__()

Returns a string representation of the statistics. Only allowed in states LSState.PAUSED or LSState.STOPPED. Useful for debugging or logging purposes.

Returns:String representation.
Return type:str