decent_bench.metrics.table_metrics#
- class decent_bench.metrics.table_metrics.TableMetric(statistics: list[Callable[[Sequence[float]], float]])[source]#
Bases:
ABCMetric to display in the statistical results table at the end of the benchmarking execution.
- Parameters:
statistics – sequence of statistics such as
min(),sum(), andaverage()used for aggregating the data retrieved withget_data_from_trial()into a single value, each statistic gets its own row in the table
- abstractmethod get_data_from_trial(agents: list[AgentMetricsView], problem: BenchmarkProblem) Sequence[float][source]#
Extract trial data to be aggregated into a single value by each of the statistics.
- class decent_bench.metrics.table_metrics.GlobalCostError(statistics: list[Callable[[Sequence[float]], float]])[source]#
Bases:
TableMetricGlobal cost error using the agents’ final x.
Global cost error is defined as:
\[| \sum_i (f_i(\mathbf{\bar{x}}) - f_i(\mathbf{x}^\star)) |\]where \(f_i\) is agent i’s local cost function, \(\mathbf{\bar{x}}\) is the mean x across all agents, and \(\mathbf{x}^\star\) is the optimal x defined in the problem.
- get_data_from_trial(agents: list[AgentMetricsView], problem: BenchmarkProblem) tuple[float][source]#
Extract trial data to be aggregated into a single value by each of the statistics.
- class decent_bench.metrics.table_metrics.GlobalGradientOptimality(statistics: list[Callable[[Sequence[float]], float]])[source]#
Bases:
TableMetricGlobal gradient optimality using the agents’ final x.
Global gradient optimality is defined as:
\[\| \frac{1}{N} \sum_i \nabla f_i(\mathbf{\bar{x}}) \|^2\]where N is the number of agents, \(f_i\) is agent i’s local cost function, and \(\mathbf{\bar{x}}\) is the mean x across all agents.
- get_data_from_trial(agents: list[AgentMetricsView], _: BenchmarkProblem) tuple[float][source]#
Extract trial data to be aggregated into a single value by each of the statistics.
- class decent_bench.metrics.table_metrics.XError(statistics: list[Callable[[Sequence[float]], float]])[source]#
Bases:
TableMetricX error per agent as defined below.
\[\{ \|\mathbf{x}_i - \mathbf{x}^\star\|, \|\mathbf{x}_j - \mathbf{x}^\star\|, ... \}\]where \(\mathbf{x}_i\) is agent i’s final x, \(\mathbf{x}_j\) is agent j’s final x, and \(\mathbf{x}^\star\) is the optimal x defined in the problem.
- get_data_from_trial(agents: list[AgentMetricsView], problem: BenchmarkProblem) list[float][source]#
Extract trial data to be aggregated into a single value by each of the statistics.
- class decent_bench.metrics.table_metrics.AsymptoticConvergenceOrder(statistics: list[Callable[[Sequence[float]], float]])[source]#
Bases:
TableMetricAsymptotic convergence order per agent as defined below.
\[\lim_{k \to \infty} \frac{\| \mathbf{x}_{k+1} - \mathbf{x}^\star \|}{\| \mathbf{x}_{k} - \mathbf{x}^\star\|^q} = \mu\]where \(\mathbf{x}_k\) is the agent’s local x at iteration k, \(\mathbf{x}^\star\) is the optimal x defined in the problem, \(q\) is the asymptotic convergence order, and \(\mu\) is the asymptotic convergence rate.
- get_data_from_trial(agents: list[AgentMetricsView], problem: BenchmarkProblem) list[float][source]#
Extract trial data to be aggregated into a single value by each of the statistics.
- class decent_bench.metrics.table_metrics.AsymptoticConvergenceRate(statistics: list[Callable[[Sequence[float]], float]])[source]#
Bases:
TableMetricAsymptotic convergence rate per agent as defined below.
\[\lim_{k \to \infty} \frac{\| \mathbf{x}_{k+1} - \mathbf{x}^\star \|}{\| \mathbf{x}_{k} - \mathbf{x}^\star\|^q} = \mu\]where \(\mathbf{x}_k\) is the agent’s local x at iteration k, \(\mathbf{x}^\star\) is the optimal x defined in the problem, \(q\) is the asymptotic convergence order, and \(\mu\) is the asymptotic convergence rate.
- get_data_from_trial(agents: list[AgentMetricsView], problem: BenchmarkProblem) list[float][source]#
Extract trial data to be aggregated into a single value by each of the statistics.
- class decent_bench.metrics.table_metrics.IterativeConvergenceOrder(statistics: list[Callable[[Sequence[float]], float]])[source]#
Bases:
TableMetricIterative convergence order per agent as defined below.
\[k = \frac{\mu}{\|\mathbf{x}_k - \mathbf{x}^\star\|^q}\]where k is the iteration, \(\mu\) is the iterative convergence rate, \(\mathbf{x}_k\) is the agent’s local x at iteration k, \(\mathbf{x}^\star\) is the optimal x defined in the problem, and \(q\) is the iterative convergence order.
As per the definition, iterative convergence is a measure of how many iterations are needed to reach a certain error. This makes iterative convergence order and rate suitable metrics for sublinear algorithms; a sublinear algorithm with iterative convergence order 0.5 generally converges significantly faster than one with order 1.
- get_data_from_trial(agents: list[AgentMetricsView], problem: BenchmarkProblem) list[float][source]#
Extract trial data to be aggregated into a single value by each of the statistics.
- class decent_bench.metrics.table_metrics.IterativeConvergenceRate(statistics: list[Callable[[Sequence[float]], float]])[source]#
Bases:
TableMetricIterative convergence rate per agent as defined below.
\[k = \frac{\mu}{\|\mathbf{x}_k - \mathbf{x}^\star\|^q}\]where k is the iteration, \(\mu\) is the iterative convergence rate, \(\mathbf{x}_k\) is the agent’s local x at iteration k, \(\mathbf{x}^\star\) is the optimal x defined in the problem, and \(q\) is the iterative convergence order.
As per the definition, iterative convergence is a measure of how many iterations are needed to reach a certain error. This makes iterative convergence order and rate suitable metrics for sublinear algorithms; a sublinear algorithm with iterative convergence order 0.5 generally converges significantly faster than one with order 1.
- get_data_from_trial(agents: list[AgentMetricsView], problem: BenchmarkProblem) list[float][source]#
Extract trial data to be aggregated into a single value by each of the statistics.
- class decent_bench.metrics.table_metrics.NrXUpdates(statistics: list[Callable[[Sequence[float]], float]])[source]#
Bases:
TableMetricNumber of iterations/updates of x per agent.
- get_data_from_trial(agents: list[AgentMetricsView], _: BenchmarkProblem) list[float][source]#
Extract trial data to be aggregated into a single value by each of the statistics.
- class decent_bench.metrics.table_metrics.NrEvaluateCalls(statistics: list[Callable[[Sequence[float]], float]])[source]#
Bases:
TableMetricNumber of cost function evaluate calls per agent.
- get_data_from_trial(agents: list[AgentMetricsView], _: BenchmarkProblem) list[float][source]#
Extract trial data to be aggregated into a single value by each of the statistics.
- class decent_bench.metrics.table_metrics.NrGradientCalls(statistics: list[Callable[[Sequence[float]], float]])[source]#
Bases:
TableMetricNumber of cost function gradient calls per agent.
- get_data_from_trial(agents: list[AgentMetricsView], _: BenchmarkProblem) list[float][source]#
Extract trial data to be aggregated into a single value by each of the statistics.
- class decent_bench.metrics.table_metrics.NrHessianCalls(statistics: list[Callable[[Sequence[float]], float]])[source]#
Bases:
TableMetricNumber of cost function hessian calls per agent.
- get_data_from_trial(agents: list[AgentMetricsView], _: BenchmarkProblem) list[float][source]#
Extract trial data to be aggregated into a single value by each of the statistics.
- class decent_bench.metrics.table_metrics.NrProximalCalls(statistics: list[Callable[[Sequence[float]], float]])[source]#
Bases:
TableMetricNumber of cost function proximal calls per agent.
- get_data_from_trial(agents: list[AgentMetricsView], _: BenchmarkProblem) list[float][source]#
Extract trial data to be aggregated into a single value by each of the statistics.
- class decent_bench.metrics.table_metrics.NrSentMessages(statistics: list[Callable[[Sequence[float]], float]])[source]#
Bases:
TableMetricNumber of sent messages per agent.
- get_data_from_trial(agents: list[AgentMetricsView], _: BenchmarkProblem) list[float][source]#
Extract trial data to be aggregated into a single value by each of the statistics.
- class decent_bench.metrics.table_metrics.NrReceivedMessages(statistics: list[Callable[[Sequence[float]], float]])[source]#
Bases:
TableMetricNumber of received messages per agent.
- get_data_from_trial(agents: list[AgentMetricsView], _: BenchmarkProblem) list[float][source]#
Extract trial data to be aggregated into a single value by each of the statistics.
- class decent_bench.metrics.table_metrics.NrSentMessagesDropped(statistics: list[Callable[[Sequence[float]], float]])[source]#
Bases:
TableMetricNumber of sent messages that were dropped per agent.
- get_data_from_trial(agents: list[AgentMetricsView], _: BenchmarkProblem) list[float][source]#
Extract trial data to be aggregated into a single value by each of the statistics.
- decent_bench.metrics.table_metrics.DEFAULT_TABLE_METRICS#
- decent_bench.metrics.table_metrics.tabulate(resulting_agent_states: dict[DstAlgorithm, list[list[AgentMetricsView]]], problem: BenchmarkProblem, metrics: list[TableMetric], confidence_level: float, table_fmt: Literal['grid', 'latex']) None[source]#
Print table with confidence intervals, one row per metric and statistic, and one column per algorithm.
- Parameters:
resulting_agent_states – resulting agent states from the trial executions, grouped by algorithm
problem – benchmark problem whose properties, e.g.
optimal_x, are used for metric calculationsmetrics – metrics to calculate
confidence_level – confidence level of the confidence intervals
table_fmt – table format, grid is suitable for the terminal while latex can be copy-pasted into a latex document