Skip to main content

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

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

decision_engine #

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 · Custom strategies · Roadmap · Contributing

Status and installation #

Initial 0.1.0 development baseline. This repository does not imply publication on pub.dev. Until a hosted release is available, use the Git source:

dependencies:
  decision_engine:
    git:
      url: https://github.com/kleberandrade/decision-engine.git
      ref: main

For reproducible applications, pin ref to a reviewed commit. Requires Dart

=3.3.0 <4.0.0; the same core can be used from Flutter.

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 pub publish --dry-run

Documentation is maintained in English and Brazilian Portuguese. AHP, sensitivity analysis and a Flutter visualization lab are planned, not implemented. See roadmap, validation and changelog.

1
likes
0
points
106
downloads

Publisher

verified publisherkleberandrade.dev

Weekly Downloads

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

Repository (GitHub)
View/report issues

Topics

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

License

unknown (license)

More

Packages that depend on decision_engine