私は なしタイプは
case class TreeNodeWithCostAndHeuristic[S,A](parent:Option[TreeNodeWithCostAndHeuristic[S,A]],
action: Option[A],
state: S,
cost: Double,
estimatedRemainingCost: Double)
この優先度キューは、他の一方で、初期状態を設定するには、そのパラメータを使用する関数内に作成されTreeNodeWithCostAndHeuristic
と呼ばれるケースクラスを注文するプライオリティキューを使用しています値は、親と行動は、私が期待タイプTreeNodeWithCostAndHeuristic[S,A]
と私は
TreeNodeWithCostAndHeuristic[S,Nothing]
をエンキューしようとしている1の間のミスマッチを取得noneですので、しかしなしとして、または0
def HeuristicGraphSearch[S,A](problem: ProblemWithCostAndHeuristic[S,A]) = {
val root = TreeNodeWithCostAndHeuristic(parent = None,action=None,state=problem.initialState,cost = 0.0, estimatedRemainingCost = 0.0)
val frontier : mutable.PriorityQueue[TreeNodeWithCostAndHeuristic[S,A]] = mutable.PriorityQueue.empty[TreeNodeWithCostAndHeuristic[S,A]]
frontier.enqueue(root)
保持する必要があります。
私の知る限り、何もOptionのサブタイプではありません。私のケースでは、parentとactionの両方がオプションです。なぜ私は不一致を得ていますか?
私はむしろ 'Option.empty'を使用したい - ここでは型帰属よりも少し立派に見えます:'アクションは= Option.empty [A] ' – Dima
@Dimaあなたは正しいかもしれませんが、私はどちらがもっと好きなのか分かりません。私は両方を追加します。 –