Fix PAI::createActionPlan() when concept node plan_selected_demand_goal not exist

It made the assumption that a concept node plan_selected_demand_goal
exit, this is apprently created by OpenPsi. PAI should not have that
kind of depence on OpenPsi, ultimately that logging code should be
moved out of that method.
Remove comment about OpenPsi PAI dependence as ActionPlan takes a demand in argument
Some minor PET -> AVATAR fix
Bug fix for issue #681
Merge pull request #682 from linas/sql

Bug fix for issue #681
Attempted fix for bug #680

Kind of annoying to fix it this way, but it seems to be needed.
Optimization for where to start a search.

Starting the pattern match search at the wrong spot can lead to horrible
performance.  So this is one possible optimization.
Another search starting point optimization

Explisitly look for the constant with the skinniest
incoming set.  This should sharply narrow down the
search space.
Fix a mis-design in the previous commit

It really should look for the thnnest, not the deepest constant.
Merge remote-tracking branch 'upstream/master' into PLNPlaytime
Preliminary cleanup, for search start point.

The next commits will re-order the clauses so that a more
efficient search can be performed. To do this, these cannot be const.
Reorder clauses to find best start point.

Loop over all the clauses, finding the one with the thinnest
incoming set, and start the search there.  This should help
performance a lot.
Clauses do not acutally have to be reordered

There is nothing special about the first clause. The
get_next_untried_clause() method does the heavy joining.
iAdd a note for future work.
Merge pull request #683 from linas/qry

Query performance optimization
Oops - remove pointless indent

Previous work left behind some grunge .. a pointless
indent in the code. Remove it.
Typoes from previous commits
Another stab at bug #680
Merge remote-tracking branch 'upstream/master' into PLNPlaytime
Pull from main repo