Im working on a modified A Star algorithm, that instead of attempting to find the shortest path, it tries to find the longest past, or in my specific case, the highest weighted path.
I have some number of classes, each with a list of unique nodes, with each node having its own value. Im attempting to determine the best possible combination of a node from each class to determine the combination or path that has the greatest weight. To do this, I am viewing these classes as a tree, with each Level having the nodes contained within a single class.
Then I search through this tree using A Star, or more specifically, im searching through my tree based on a search stack. Once a node is explored, its children are inserted in a sorted order based on their weight (plus their ancestors weight) plus the possible future weight (my heuristic). Then the top of the stack, with the highest value is selected to search next.
To do this I have an overestimating heuristic, that is it never underestimates the the optimal solution.
If I am looking for the highest weight and not the lowest weight, is this heuristic admissible, and thus my algorithm optimal?
PS: A FormalIsh defination of the current algorithm.
Let S = {S1, S2, ... , Sn}
and each Si has a set of items and a NULL, which represents an item not chosen from this set.
Si = {I1, I2, ... , Im, NULL}
Also each item only ever exists in one set, IE Si U Sj = Si + Sj
Each Item, Ii has an associated value, Vi.
The problem is to select a maximum of M offers, one from each set, when summed yield the highest value. I call this selection a Path, Pi. A path can be complete, meaning it has a selection from all S, or it can be partial where only x offers are contained within it. Also M
In addition, there exists a function IsCompatable(path) that returns true if a path is compatible. Whether a path is compatible or is completely arbitrary. The Max valued path must be compatible. This is why I can not trivially select the M largest Items from each set.
In addition each set contains a NULL item, so that an item need not be selected from that set.
The Trivial Algorithm would to make a search tree and generate all possible combinations of items in S, with each path to the trees leaves said to be a path.
let G(P) be the current value (the summed value of each item) of the partial path. Let H(P) be an estimation (heuristic) of the value of the future path. H(P) = The Y values from Y items from Y Si in S. Each item is the item with the maximum value in the Si where i > len(P). Y = M - the current length of the partial path P.
To Find the path with the greatest value, I keep a sorted Queue of partial paths, sorted on their values + their possible future values, ie G(Pi) + H(Pi). I Initialize this Queue by adding paths contained in S1.
While the Queue is not empty or a path has not been found:
p = Pop the path from the top of Q
if p is Complete:
A full path has been found
return p
find the possible children of p by adding an item to p from the next set.
for child in Children:
if IsCompatable(child):
add child back to Q in sorted order on G(child) + H(child)
There it is, now is my Heuristic admissible?