autopilot/interface+externalscoreattach: define ScoreSettable

ScoreSettable is an interface that let caller set external scores for
the heuristic. The ExternalScoreAttachment and WeightedCombAttachment
heuristics implement this interface.
This commit is contained in:
Johan T. Halseth committed 2019-02-14 11:41:47 +01:00
1 parent 83edcb7153
commit b23e53ea33
3 files changed
+24 -3

No files matched your search

+5 -2
View File
@@ -25,7 +25,7 @@ type WeightedCombAttachment struct {
// NewWeightedCombAttachment creates a new instance of a WeightedCombAttachment.
func NewWeightedCombAttachment(h ...*WeightedHeuristic) (
AttachmentHeuristic, error) {
*WeightedCombAttachment, error) {
// The sum of weights given to the sub-heuristics must sum to exactly
// 1.0.
@@ -44,8 +44,9 @@ func NewWeightedCombAttachment(h ...*WeightedHeuristic) (
}
// A compile time assertion to ensure WeightedCombAttachment meets the
// AttachmentHeuristic interface.
// AttachmentHeuristic and ScoreSettable interfaces.
var _ AttachmentHeuristic = (*WeightedCombAttachment)(nil)
var _ ScoreSettable = (*WeightedCombAttachment)(nil)
// Name returns the name of this heuristic.
//
@@ -135,6 +136,8 @@ func (c *WeightedCombAttachment) NodeScores(g ChannelGraph, chans []Channel,
//
// Since this heuristic doesn't keep any internal scores, it will recursively
// apply the scores to its sub-heuristics.
//
// NOTE: This is a part of the ScoreSettable interface.
func (c *WeightedCombAttachment) SetNodeScores(targetHeuristic string,
newScores map[NodeID]float64) (bool, error) {