# Path: sas/operators.py
# class Axiom(Operator):
#   cost = 0


from .hsp import *
from .operators import Axiom
      if value in marked[level][var]: continue
      if ALL_BACK_POINTERS:
        easiest_operator = argmin(lambda o: EASIEST_HEURISTIC(o, operator_costs, variable_costs, goals),
          (o for o, n in operator_costs.items() if n.level < level and var in o.effects and o.effects[var] == value))
      else:
        easiest_operator = argmin(lambda o: EASIEST_HEURISTIC(o, operator_costs, variable_costs, goals),
          (o for o in operator_layers[level-1] if var in o.effects and o.effects[var] == value))
      plan[level-1].add(easiest_operator)
      for var2, value2 in easiest_operator.conditions.items():
        if value2 not in marked[level-1][var2]:
          goals[variable_costs[var2][value2].level][var2].add(value2)
      for var2, value2 in easiest_operator.effects.items():
        marked[level][var2].add(value2)
        marked[level-1][var2].add(value2) # Assumes that actions are read off in order they are selected (no need to reachieve)
  return plan, goals

###########################################################################

def plan_cost(goal, operator_costs, relaxed_plan, relaxed_goals):
  return sum(operator.cost for operator in flatten(relaxed_plan))

def plan_length(goal, operator_costs, relaxed_plan, relaxed_goals):
  return len(flatten(relaxed_plan))

def multi_cost(goal, operator_costs, relaxed_plan, relaxed_goals):
  return plan_cost(goal, operator_costs, relaxed_plan, relaxed_goals), operator_costs[goal].cost, operator_costs[goal].level

###########################################################################

def filter_axioms(operators):

# Path: sas/operators.py
# class Axiom(Operator):
#   cost = 0


# Path: sas/ff.py
from .hsp import *
from .operators import Axiom

      if value in marked[level][var]: continue
      if ALL_BACK_POINTERS:
        easiest_operator = argmin(lambda o: EASIEST_HEURISTIC(o, operator_costs, variable_costs, goals),
          (o for o, n in operator_costs.items() if n.level < level and var in o.effects and o.effects[var] == value))
      else:
        easiest_operator = argmin(lambda o: EASIEST_HEURISTIC(o, operator_costs, variable_costs, goals),
          (o for o in operator_layers[level-1] if var in o.effects and o.effects[var] == value))
      plan[level-1].add(easiest_operator)
      for var2, value2 in easiest_operator.conditions.items():
        if value2 not in marked[level-1][var2]:
          goals[variable_costs[var2][value2].level][var2].add(value2)
      for var2, value2 in easiest_operator.effects.items():
        marked[level][var2].add(value2)
        marked[level-1][var2].add(value2) # Assumes that actions are read off in order they are selected (no need to reachieve)
  return plan, goals

###########################################################################

def plan_cost(goal, operator_costs, relaxed_plan, relaxed_goals):
  return sum(operator.cost for operator in flatten(relaxed_plan))

def plan_length(goal, operator_costs, relaxed_plan, relaxed_goals):
  return len(flatten(relaxed_plan))

def multi_cost(goal, operator_costs, relaxed_plan, relaxed_goals):
  return plan_cost(goal, operator_costs, relaxed_plan, relaxed_goals), operator_costs[goal].cost, operator_costs[goal].level

###########################################################################

def filter_axioms(operators):

  return list(filter(lambda o: not isinstance(o, Axiom), operators))