Cannot run cog-execute! function.

32 views
Skip to first unread message

Gaurav Gautam

unread,
Jul 4, 2016, 11:34:22 AM7/4/16
to opencog
Hello,

I have installed opencog in a custom location using the -DCMAKE_INSTALL_PREFIX and other such options. I did
this so that whenever I really mess up things and need to start over I can just delete the whole install directory and
start again.

Currently, I can run the cogserver and create links and nodes using the scheme shell. However, when I try to run cog-execute!
I get an error.  I have edited the LTDL_LIBRARY_PATH in the scheme modules in local/share/scm to point to the
appropriate directories. 

I know all of you are busy with AGI right now, so if there isn't anything obviously wrong then I will try running the script
after installing in /usr/local as opecog does by default.

Here is the code I am running:

----------------
(use-modules (ice-9 readline))
(activate-readline)
(add-to-load-path "/home/gaurav/Codes/AI/OpenCog/SOFTWARE/local/share/opencog/scm")
(add-to-load-path ".")
(use-modules (opencog))
(use-modules (opencog query))
(use-modules (opencog exec))
(load-from-path "opencog.scm")
(display "-----------------------------------------------------------------------")
(newline)(newline)

;cog-execute! is a opencog exec function that knows how to execute certain links.
;It will be used in this script.

;PlusLink: For adding numbers
(define link
      (cog-new-link 'PlusLink
          (cog-new-node 'NumberNode 2)
        (cog-new-node 'NumberNode 3)
    )
)
(cog-execute! link)

-----------------------

The error I get is this:

Backtrace:
In ice-9/boot-9.scm:
 157: 7 [catch #t #<catch-closure 1621400> ...]
In unknown file:
   ?: 6 [apply-smob/1 #<catch-closure 1621400>]
In ice-9/boot-9.scm:
  63: 5 [call-with-prompt prompt0 ...]
In ice-9/eval.scm:
 432: 4 [eval # #]
In ice-9/boot-9.scm:
2320: 3 [save-module-excursion #<procedure 1653d40 at ice-9/boot-9.scm:3961:3 ()>]
3968: 2 [#<procedure 1653d40 at ice-9/boot-9.scm:3961:3 ()>]
In unknown file:
   ?: 1 [load-compiled/vm "/home/gaurav/.cache/guile/ccache/2.0-LE-8-2.0/home/gaurav/Codes/AI/OpenCog/WORKSPACE/AtomTypes/links.scm.go"]
In /home/gaurav/Codes/AI/OpenCog/WORKSPACE/AtomTypes/links.scm:
  16: 0 [#<procedure 1652700 ()>]

/home/gaurav/Codes/AI/OpenCog/WORKSPACE/AtomTypes/links.scm:16:0: In procedure #<procedure 1652700 ()>:
/home/gaurav/Codes/AI/OpenCog/WORKSPACE/AtomTypes/links.scm:16:0: In procedure module-lookup: Unbound variable: cog-execute!

Yours sincerely
Gaurav Gautam

Linas Vepstas

unread,
Jul 4, 2016, 7:22:46 PM7/4/16
to opencog

On Mon, Jul 4, 2016 at 10:34 AM, Gaurav Gautam <gauta...@gmail.com> wrote:
(use-modules (opencog exec))

There error message mentions /home/gaurav/Codes/AI/OpenCog/WORKSPACE/AtomTypes/links.scm but you did not say what it contains.

--linas

Gaurav Gautam

unread,
Jul 4, 2016, 8:37:53 PM7/4/16
to opencog
The contents of links.scm are the program that I included in the post (in blue). So I run it as $guile links.scm

Gaurav Gautam

unread,
Jul 5, 2016, 12:53:53 AM7/5/16
to opencog, linasv...@gmail.com
Hello Linas,

So I did something and now I can run the cog-execute! function. However, I don't understand what I did or how it
worked. I need a little help in understanding what I did.

The wiki page:

http://wiki.opencog.org/wikihome/index.php/Scheme

asks us to add this boilerplate code to the guile scripts:

scheme@(guile-user)> (use-modules (ice-9 readline)) (activate-readline)
scheme@(guile-user)> (add-to-load-path "/usr/local/share/opencog/scm")
scheme@(guile-user)> (add-to-load-path ".")
scheme@(guile-user)> (use-modules (opencog))
scheme@(guile-user)> (use-modules (opencog query))
scheme@(guile-user)> (use-modules (opencog exec))
scheme@(guile-user)> (load-from-path "opencog.scm")
 
After adding some (display "Message") statements in opencog/query.scm and opencog/exec.scm I noticed that
these were not getting executed. So I added two more lines to the boilerplate code:

(load-from-path "opencog/exec.scm)
(load-from-path "opencog/query.scm")

Is this normal? Are we supposed to load a scheme module using a combination of use-modules and load-from-path?
I don't understand what load-from-path is doing. I have tried to google this but I always end up in the GNU manuals and
they are quite cryptic about this.

Yours sincerely
Gaurav Gautam
Reply all
Reply to author
Forward
0 new messages