Skip to main content

decision_engine 0.2.0 copy "decision_engine: ^0.2.0" to clipboard
decision_engine: ^0.2.0 copied to clipboard

Explainable multicriteria decisions in pure Dart, with AHP criterion weighting, weighted sum, TOPSIS, hard constraints and immutable calculation traces.

decision_engine #

pub package pub points

Dart CI Dart SDK License: MIT

Explainable multicriteria decisions in pure Dart for Flutter apps and Dart services. Compose criteria, eligibility requirements and ranking strategies. No runtime dependencies, Flutter imports, IO or network access in the core.

Português · Getting started · Methods and equations · Architecture · AHP weighting · Custom strategies · Roadmap · Contributing

Status and installation #

This source is 0.2.0, introducing AHP criterion weighting. It remains pure Dart and requires Dart >=3.3.0 <4.0.0. Check the pub.dev version list for hosted availability; source versioning does not itself publish a package. The package belongs to verified publisher kleberandrade.dev.

For the 0.2.0 release:

dependencies:
  decision_engine: ^0.2.0

Run dart pub add decision_engine or flutter pub add decision_engine to select the latest available compatible hosted version. AHP requires 0.2.0 or newer; the published 0.1.0 API does not include it. To use this source before hosted publication, use a Git dependency pinned to a reviewed commit on main. The previous v0.1.0 source release remains available; its pub.dev analysis reached 160 points.

Choose a provider #

import 'package:decision_engine/decision_engine.dart';

void main() {
  final engine = DecisionEngine(
    criteria: [
      Criterion.minimize('cost', weight: 0.35),
      Criterion.minimize('latency', weight: 0.25),
      Criterion.maximize('availability', weight: 0.40),
    ],
    constraints: [MinimumValue('availability', 99.9)],
    method: const Topsis(),
  );

  final result = engine.evaluate([
    Alternative('Provider A', values: {
      'cost': 1200, 'latency': 25, 'availability': 99.95,
    }),
    Alternative('Provider B', values: {
      'cost': 1600, 'latency': 15, 'availability': 99.99,
    }),
    Alternative('Provider C', values: {
      'cost': 900, 'latency': 40, 'availability': 99.5,
    }),
  ]);

  print(result.best?.name);
  for (final entry in result.ranking) {
    print('${entry.rank}: ${entry.alternative.name} = ${entry.score}');
  }
  print(result.excluded.single.reasons);
  print(result.trace?.normalized);
}

Provider C is excluded before normalization. Use const WeightedSum() to select direction-aware min-max normalization with additive weighted contributions. Run the full example with dart run example/decision_engine_example.dart.

Included methods #

Strategy Normalization Result Best fit
WeightedSum Min-max, oriented to preference Sum of weighted utilities Transparent additive trade-offs
Topsis Column Euclidean vector norm Closeness to ideal / distance from anti-ideal Ideal-point comparisons

Both methods accept signed finite observations and nonnegative relative weights. Weights are normalized automatically; at least one must be positive. Zero weights remove the corresponding criterion's influence on ranking. Hard constraints on that criterion still apply. Constant columns cannot distinguish alternatives. See method conventions and limitations.

Inspect the decision #

  • ranking: descending scores with competition ranks (1, 1, 3). Exact ties preserve input order; best is the first tied alternative, not a unique winner.
  • excluded: original alternatives with every failed requirement.
  • criteria and weights: column identities and normalized relative weights.
  • eligible: original input row order, used by all trace matrices.
  • trace.normalized and trace.weighted: immutable calculation matrices.
  • TOPSIS trace.diagnostics: distanceToIdeal and distanceToAntiIdeal per row.

Empty input or an entirely rejected set returns best == null, an empty ranking and trace == null. Scores belong to one method and eligible set; do not compare them across methods or treat them as probabilities. Adding or removing options can change normalization and the ranking, even for unchanged alternatives.

Extend without changing the engine #

Implement DecisionMethod or DecisionConstraint and compose it through the public entry point. See custom method example. Strategies must return finite, dimensionally correct traces; the engine checks this boundary. Tests and consumers import package:decision_engine/decision_engine.dart.

Development #

dart pub get
dart analyze --fatal-infos
dart test
dart run example/decision_engine_example.dart
dart run example/weighted_sum.dart
dart run example/custom_method.dart
dart run example/ahp.dart
dart pub publish --dry-run

Documentation is maintained in English and Brazilian Portuguese. AHP criterion weighting is implemented; sensitivity analysis and a Flutter visualization lab remain planned. See roadmap, validation and changelog.

Generate weights with AHP #

This section describes the 0.2.0 API. It is not available in hosted 0.1.0.

Use AhpWeighting().evaluate(criterionIds: ..., comparisons: ...) to derive principal-eigenvector weights from 1–10 reciprocal comparisons. Inspect CI/CR, then call toCriteria with explicit maximize/minimize directions. Inconsistent judgments are rejected by this conversion unless explicitly opted into. See the AHP guide and example/ahp.dart for the complete workflow.

1
likes
160
points
106
downloads

Documentation

API reference

Publisher

verified publisherkleberandrade.dev

Weekly Downloads

Explainable multicriteria decisions in pure Dart, with AHP criterion weighting, weighted sum, TOPSIS, hard constraints and immutable calculation traces.

Repository (GitHub)
View/report issues
Contributing

Topics

#decision-making #multicriteria #topsis #optimization #dart

License

MIT (license)

More

Packages that depend on decision_engine