Source code for concepts.dm.pdsketch.strips.strips_search

#! /usr/bin/env python3
# -*- coding: utf-8 -*-
# File   : strips_search.py
# Author : Jiayuan Mao
# Email  : maojiayuan@gmail.com
# Date   : 03/20/2022
#
# This file is part of Project Concepts.
# Distributed under terms of the MIT license.

import jacinle
import jactorch
from typing import Callable

from concepts.dm.pdsketch.strips.strips_expression import SState
from concepts.dm.pdsketch.strips.strips_grounding import GStripsProblem
from concepts.dm.pdsketch.strips.strips_heuristics import StripsHeuristic
from concepts.algorithm.search.heuristic_search import run_heuristic_search

__all__ = ['strips_brute_force_search', 'strips_heuristic_search', 'get_priority_func']










[docs] def get_priority_func(heuristic: Callable[[SState], float], weight: float) -> Callable[[SState, int], float]: if weight == 1: def priority_fun(state, g, heuristic=heuristic): return heuristic(state) + g elif weight == float('inf'): def priority_fun(state, g, heuristic=heuristic): return heuristic(state) else: def priority_fun(state, g, heuristic=heuristic, weight=weight): return heuristic(state) + g * weight return priority_fun