On Wed, May 26, 2021 at 5:08 AM Anatoly Belikov <[email protected]> wrote:
> It was my suggestion to represent search states with ContexLinks, somehow > like that: > Did you mean "represent state transition rules"? A state transition rule has the form "if (lots of preconditions) then (a move to state1 is allowed)" I don't recall if we have any preferred or recommended way of writing those. There is a sequence of four state-machine demos, each building on the last: https://github.com/opencog/atomspace/blob/master/examples/pattern-matcher/fsm-basic.scm https://github.com/opencog/atomspace/blob/master/examples/pattern-matcher/fsm-full.scm https://github.com/opencog/atomspace/blob/master/examples/pattern-matcher/fsm-mealy.scm https://github.com/opencog/atomspace/blob/master/examples/pattern-matcher/markov-chain.scm I notice that the last three use ContextLink to represent state transition rules. This might be an abuse or misuse of ContextLinks. Certainly, the wiki page for them https://wiki.opencog.org/w/ContextLink suggests something very different. The four examples above were written before StateLink was invented, and before Values. They should be reviewed, and maybe re-written or modernized. Anatoly, would you care to do this? Maybe Michele could be a guinea pig, and tell us what's wrong or unclear about these demos? The nice thing about StateLink is that it is atomic: There can only ever be one; there are never accidentally two or zero, and it is thread-safe: even if multiple threads are all setting the state at the same time, there will always be just one. The "ugly thing" about StateLink is that its an Atom, and thus the fastest rate of change is limited by AtomSpace insertion, deletion, which is in the ballpark of 50K/second, depending on how old your CPU is and what language you are using (c++/python/scheme). Value changes are much much faster, I think in the 200K/second or 500K/second range. Certainly, the basic blocksworld can be represented as a kind of stateful system, and the goal of the URE would then be to find a sequence of moves to get from some position to another. We really should have a documented, maintained example for the "recommended way of doing this". Ideally, it would use the same kind of rule-style as the above four examples, so that all the demos are consistent. I have no clue why the URE is misbehaving.... is it being used incorrectly, or is it broken? Do I need to personally look at this? --linas > (ContexLink > (ConceptNode "state1") > (AndLink ( > (ConceptNode "state0") ; previous state > EvaluationLink (stv 0 1) > (PredicateNode "not-free") > (ConceptNode "block5"))) ; and so on, here > are all valid combinations of predicates and it's arguments like in c++ > planners i am familiar with. > > Now I believe it makes sense to represent the state using values, maybe > just with LinkValue and accessor functions. > The research direction might be the integration of heuristic function into > URE for selection of the next state to expand. > > ср, 26 мая 2021 г. в 01:39, Linas Vepstas <[email protected]>: > >> Let me balance my earlier theoretical remarks with some clarifications. >> >> -- Bindlinks are more-or-less pure crisp-logic things. Any single one >> gives a pure, crisp true/false result, and you can certainly write solvers >> with them. >> >> -- The PLN rules are ways of assembling them into inference trees with >> non-crisp probabilistic results. >> >> -- Anatoly's idea sounds like a good one to me. Anything you can do to >> limit the search space is always a good thing. Things like >> >> (PresentLink >> (InheritanceLink >> (VariableNode "?ob") >> (ConceptNode "object"))) >> >> can vastly speed the search by limiting it only to those ?ob's that are >> actually objects, instead of trying everything under the sun. This is very >> useful in intermediate steps, to avoid combinatoric explosion. >> >> -- I have no clue what ContextLinks are good for. That's a PLN thing. >> >> Linas. >> >> >> >> On Tue, May 25, 2021 at 10:11 AM Michele Thiella <[email protected]> >> wrote: >> >>> For now I have only added the ContentLinks and the rules to work with to >>> solve the BC of the blocksworld problem >>> (for example the put-down and unstack rules are missing). >>> >>> It is true that I do not take into account a full state when I do an >>> action. >>> This would make sense in a general case, so that any action that is >>> added is correct regardless of the others, because it is based only on the >>> state. >>> >>> Instead, the correctness of my current structure lies in the last >>> bindlink, the one that corresponds to the complete inference tree that >>> solves my goal. >>> The conditions for replacing VariableNodes with ConceptNodes are >>> accumulated among the various rules used in the tree. >>> So at the end the blocks will be stacked correctly and the result will >>> correspond to the probabilistic permutations of the n blocks on the table >>> taken at X (= number of blocks in my column) >>> >>> For now it works (except for this RAM problem), but the unstack and >>> put-down rules are not there, because they are actually not needed for >>> correct planning. >>> >>> I feel like I'm a bit cheating. >>> If the correct idea is to use a state it will be good to rewrite the >>> rules. >>> >>> Although, I didn't quite understand what the problem with my structure >>> is. >>> If I do BC I can't have partial solutions so I just need the final >>> bindlink to contain all the necessary conditions, I don't need them to be >>> verified for every rule. >>> >>> Certainly I have not explained well, perhaps because I have not >>> understood the matter well. >>> >>> Michele >>> Il giorno martedì 25 maggio 2021 alle 16:11:37 UTC+2 [email protected] >>> ha scritto: >>> >>>> You introduced ContextLinks, but it doesn't provide full state for each >>>> action. For example in pickup you create (EvaluationLink (PredicateNode >>>> "not-clear") (VariableNode "?ob")) for some object "?ob", but there are >>>> probably other objects that are not free. In c++ we can represent a state >>>> by boolean array. When applying some action we would copy the bit-vector of >>>> the previous state and modify some bits. You can emulate this behaviour by >>>> using ConceptNodes for states. You can store values of all boolean >>>> variables as properties of ConceptNode. You will have to rewrite >>>> preconditions to call to python or scheme function: >>>> >>>> ; precondition of pickup-action >>>> (AndLink >>>> (PresentLink >>>> (InheritanceLink >>>> (VariableNode "?state") >>>> (ConceptNode "state"))) >>>> (PresentLink >>>> (InheritanceLink >>>> (VariableNode "?ob") >>>> (ConceptNode "object"))) >>>> (EvaluationLink >>>> (GroundedPredicateNode "py: can_pickup"), >>>> ListLink( >>>> (VariableNode "?state") >>>> (VariableNode "?ob") >>>> ) >>>> ) >>>> >>>> in can_pickup you check if passed (state, object) pair satisfies the >>>> precondition. >>>> >>>> In ExectionOutputLink you can create a new ConceptNode for a new state >>>> by copying all the properties from the previous state with necessary >>>> changes. >>>> >>>> >>>> пн, 24 мая 2021 г. в 20:27, Michele Thiella <[email protected]>: >>>> >>>>> Hello everyone, >>>>> >>>>> Finally, I was able to pass the first planning test for the blocksword >>>>> problem, using ContextLinks. >>>>> (For now, it has some ad-hoc things/rules and others that are missing) >>>>> >>>>> But, as long as I look for a column of 3 blocks everything is fine and >>>>> the times for the BC are very short, >>>>> while when I look for a column of 4 or more I go into RAM overflow. >>>>> Unfortunately, I'm on Linux on an external sdd and the Swap area is >>>>> there. >>>>> Consequently, with a goal of 4 blocks, I use more than 8 Giga (I only >>>>> have 8) and it starts swapping but the time gets longer and I can't finish >>>>> the execution. >>>>> >>>>> Would anyone be able to run the test_pickup_stack.scm file? and share >>>>> me the log file? >>>>> it's in my repo: https://github.com/raschild6/blocksworld_problem >>>>> Thanks a lot in advance! >>>>> (There should be no errors, just do (load >>>>> "path/to/file/test_pickup_stack.scm") in the telnet shell. Report me if >>>>> there is something wrong, thanks!) >>>>> >>>>> I'm playing with the URE parameters to see if I can optimize the >>>>> inference. >>>>> (extra question) is there a URE parameter to terminate at the first BC >>>>> solution found? >>>>> >>>>> Michele >>>>> >>>>> -- >>>>> >>>> You received this message because you are subscribed to the Google >>>>> Groups "opencog" group. >>>>> To unsubscribe from this group and stop receiving emails from it, send >>>>> an email to [email protected]. >>>>> >>>> To view this discussion on the web visit >>>>> https://groups.google.com/d/msgid/opencog/4f5a4761-3ad7-4d6c-87d6-f5bb1f16f993n%40googlegroups.com >>>>> <https://groups.google.com/d/msgid/opencog/4f5a4761-3ad7-4d6c-87d6-f5bb1f16f993n%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>> . >>>>> >>>> -- >>> You received this message because you are subscribed to the Google >>> Groups "opencog" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/opencog/b0effc4c-a09e-4f55-a00c-a4e16bb17f24n%40googlegroups.com >>> <https://groups.google.com/d/msgid/opencog/b0effc4c-a09e-4f55-a00c-a4e16bb17f24n%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >> >> >> -- >> Patrick: Are they laughing at us? >> Sponge Bob: No, Patrick, they are laughing next to us. >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "opencog" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/opencog/CAHrUA37r38daLXGaN%2BJmYmm0KgDkacnV7a60pE%3D%2BE0M5DY7s4g%40mail.gmail.com >> <https://groups.google.com/d/msgid/opencog/CAHrUA37r38daLXGaN%2BJmYmm0KgDkacnV7a60pE%3D%2BE0M5DY7s4g%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> > -- > You received this message because you are subscribed to the Google Groups > "opencog" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/opencog/CAFj%2Bw-sWotMa6CPpMiUDMywDS0P-4FDji75YnNoS6M3jwoznyQ%40mail.gmail.com > <https://groups.google.com/d/msgid/opencog/CAFj%2Bw-sWotMa6CPpMiUDMywDS0P-4FDji75YnNoS6M3jwoznyQ%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- Patrick: Are they laughing at us? Sponge Bob: No, Patrick, they are laughing next to us. -- You received this message because you are subscribed to the Google Groups "opencog" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/opencog/CAHrUA374OfZazwhmFjXseh0PRGN5NBwB1-6C6BdXLqkxx5gCtw%40mail.gmail.com.
