ExVrp.Statistics (ExVrp v0.4.2)

Copy Markdown View Source

Statistics about the search progress.

Collects data about solution costs and feasibility during optimization, allowing analysis of the search trajectory.

Example

stats = ExVrp.Statistics.new()
stats = ExVrp.Statistics.collect(stats, current, candidate, best, cost_evaluator)
Enum.each(stats, fn datum -> IO.inspect(datum) end)

Summary

Functions

Returns whether this Statistics object is collecting data.

Reads a Statistics object from a CSV file.

Creates a new Statistics object.

Writes this Statistics object to a CSV file.

Types

datum()

@type datum() :: %{
  current_cost: integer(),
  current_feas: boolean(),
  candidate_cost: integer(),
  candidate_feas: boolean(),
  best_cost: integer(),
  best_feas: boolean()
}

t()

@type t() :: %ExVrp.Statistics{
  clock: integer(),
  collect_stats: boolean(),
  data: [datum()],
  num_iterations: non_neg_integer(),
  runtimes: [float()]
}

Functions

collect(stats, current, candidate, best, cost_evaluator)

@spec collect(t(), reference(), reference(), reference(), reference()) :: t()

Collects iteration statistics.

Parameters

  • stats - The Statistics object
  • current - The current solution reference
  • candidate - The candidate solution reference
  • best - The best solution reference
  • cost_evaluator - CostEvaluator reference used to compute costs

collecting?(statistics)

@spec collecting?(t()) :: boolean()

Returns whether this Statistics object is collecting data.

from_csv(path, opts \\ [])

@spec from_csv(
  Path.t(),
  keyword()
) :: {:ok, t()} | {:error, term()}

Reads a Statistics object from a CSV file.

Parameters

  • path - File path to read from
  • opts - Options (:delimiter defaults to ,)

new(opts \\ [])

@spec new(keyword()) :: t()

Creates a new Statistics object.

Options

  • :collect_stats - Whether to collect statistics. Can be turned off to avoid excessive memory use on long runs. Defaults to true.

to_csv(stats, path, opts \\ [])

@spec to_csv(t(), Path.t(), keyword()) :: :ok | {:error, term()}

Writes this Statistics object to a CSV file.

Parameters

  • stats - The Statistics object
  • path - File path to write to
  • opts - Options (:delimiter defaults to ,)