langgoap.pareto_plans

Contents

langgoap.pareto_plans#

pareto_plans(plans, goal, *, scale=1000, max_frontier=None)[source]#

Enumerate the Pareto-optimal subset of candidate plans.

From a finite set of candidate plans, returns the non-dominated subset (Pareto frontier) ordered by primary objective value. A plan A dominates plan B when A is at least as good on all objectives and strictly better on at least one.

Hard constraints are respected: plans violating any hard ConstraintSpec are excluded from the frontier entirely before dominance is computed.

When goal.objectives is empty or None, every feasible plan is non-dominated (no objective can distinguish them) and the full feasible set is returned (subject to max_frontier) sorted by plan cost.

Parameters:
  • plans (list['Plan']) – Candidate plans. Typically produced by running A* with different starting states, action subsets, or by LazyDecompositionStrategy.

  • goal (GoalSpec) – Goal spec with constraints and objectives.

  • scale (int) – Integer scaling factor for resource computations (forwarded to validate_plan()).

  • max_frontier (int | None) – Cap on the number of returned frontier plans. The max_frontier plans with the best primary-objective value are kept. None returns all non-dominated plans.

Returns:

A list of (Plan, CSPMetadata) tuples for non-dominated plans, ordered by the primary (first) objective value. Empty when all plans are infeasible or the input list is empty.

Raises:

ValueError – When plans is empty.

Return type:

list[tuple[‘Plan’, CSPMetadata]]