create a new heuristic

133 views
Skip to first unread message

idan himlich

unread,
May 23, 2013, 3:35:28 AM5/23/13
to fast-d...@googlegroups.com
hi,

we want to run the FD with a new heuristic we have created.
can someone please instruct us how to do so? we could not figure it out from the information on the website.

thanks,
idan.

Malte Helmert

unread,
May 23, 2013, 4:38:40 AM5/23/13
to fast-d...@googlegroups.com, idan himlich
Start by copying a simple heuristic, like the goal count heuristic
(goal_count_heuristic.{h,cc}). Change the line at the bottom:

static Plugin<ScalarEvaluator> _plugin("goalcount", _parse);

to use a different string, e.g.

static Plugin<ScalarEvaluator> _plugin("idan_heuristic", _parse);

and you can use the new heuristic in the planner with the name
"idan_heuristic" on the command line.

(You'll also have to add "idan_heuristic.h" to the "HEADERS" variable in
the Makefile.)

Once that works, I'd suggest starting with the actual implementation of
the heuristic you want to implement.

Cheers,
Malte

Gabi Roeger

unread,
May 23, 2013, 4:39:40 AM5/23/13
to fast-d...@googlegroups.com
Dear Idan,
Maybe have a look at the goal_count_heuristic, which is very simple, for
an example.

1. Your heuristic needs to derive from Heuristic.
2. You need to add the header file to the Makefile.
3. You need to add a plugin section to your heuristic, which specifies
the "keyword" on the commandline.

The simplest case is a heuristic that does not need any additional
parameters. Then you simply can add the followin section to the
implementation file:


static ScalarEvaluator *_parse(OptionParser &parser) {
Heuristic::add_options_to_parser(parser);
Options opts = parser.parse();
if (parser.dry_run())
return 0;
else
return new YourHeuristic(opts);
}


static Plugin<ScalarEvaluator> _plugin("nameofyourheuristic", _parse);


If you need additional parameters for your heuristic, please write again
for further instructions.

Cheers,
Gabi

idan himlich

unread,
May 23, 2013, 5:01:19 AM5/23/13
to fast-d...@googlegroups.com
thank you all for the quick replies. i will try it now .. :) 

Marvin Abisrror

unread,
Sep 24, 2014, 1:34:07 PM9/24/14
to fast-d...@googlegroups.com
Hello,

I have copied and pasted with another name the files goal_count_heuristic.{h,cc} and modified the file Makefile in the /search directory, but
after testing I get an error message.

I was wondering if should I compile in some way the file Makefile in order to recognize my changes.

Any answer about this problem I am having will be welcome and let me thank in advance.

Regards

Malte Helmert

unread,
Sep 24, 2014, 1:38:24 PM9/24/14
to fast-d...@googlegroups.com
On 24.09.2014 19:34, Marvin Abisrror wrote:
> Hello,
>
> I have copied and pasted with another name the files
> goal_count_heuristic.{h,cc} and modified the file Makefile in the
> /search directory, but
> after testing I get an error message.
>
> I was wondering if should I compile in some way the file Makefile in
> order to recognize my changes.
>
> Any answer about this problem I am having will be welcome and let me
> thank in advance.
>
> Regards

Hi Marvin,

no, the Makefile doesn't need compiling. Can you tell us which error
message you get?

Cheers,
Malte

Gabi Röger

unread,
Sep 24, 2014, 1:40:41 PM9/24/14
to fast-d...@googlegroups.com
Hi,


On 09/24/2014 07:34 PM, Marvin Abisrror wrote:

I have copied and pasted with another name the files goal_count_heuristic.{h,cc} and modified the file Makefile in the /search directory, but
after testing I get an error message.
Have you renamed the classes in the copied file?

In the last line of the .cc file, have you replaced the string "goalcount" with something else?

Cheers,
Gabi

--
You received this message because you are subscribed to the Google Groups "Fast Downward" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fast-downwar...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Marvin Abisrror

unread,
Sep 24, 2014, 2:10:06 PM9/24/14
to fast-d...@googlegroups.com
Hello Malte,

The heuristic name I have is "ss" and the message I am getting is attached in the file
testing-opt-strips10.txt

Also I am attaching the heuristic files:
ss_heuristic.cc
ss_heuristic.h

Regards.
testing-opt-strips10.txt
ss_heuristic.cc
ss_heuristic.h

Gabi Röger

unread,
Sep 24, 2014, 2:15:37 PM9/24/14
to fast-d...@googlegroups.com
Hi,

due to the
#ifndef GOAL_COUNT_HEURISTIC_H
#define GOAL_COUNT_HEURISTIC_H

in ss_heuristic.h, the header is not really compiled (assuming that the goal count heuristic is mentioned first in the Makefile).
What happens if you rename it appropriately?

Cheers,
Gabi
--

Malte Helmert

unread,
Sep 24, 2014, 2:19:27 PM9/24/14
to fast-d...@googlegroups.com
On 24.09.2014 20:15, Gabi Röger wrote:
> Hi,
>
> due to the
> #ifndef GOAL_COUNT_HEURISTIC_H
> #define GOAL_COUNT_HEURISTIC_H
>
> in ss_heuristic.h, the header is not really compiled (assuming that the
> goal count heuristic is mentioned first in the Makefile).
> What happens if you rename it appropriately?

Gabi, you're right that this should be fixed, but it will only cause a
problem if goal_count_heuristic.h and ss_heuristic.h are included from
the same source file (directly or indirectly), which I think isn't the case.

Here's another problem:

static ScalarEvaluator *_parse(OptionParser &parser) {
Heuristic::add_options_to_parser(parser);
Options opts = parser.parse();
if (parser.dry_run())
cout<<"goal uno"<<"\n\n";
return 0;
else
cout<<"SSHeuristic ..."<<"\n\n";
return new SSHeuristic(opts);
}

The if/else blocks don't have parentheses, and therefore the "return 0;"
is not part of the "if" and will be executed unconditionally, which
would cause problems. I don't see how this could compile, though,
because the "else" doesn't belong to any "if" here for the same reason.
The "goal uno" output should also be visible in the output, but isn't.

Marvin, is it possible this is not the same code you used to run the code?

Cheers,
Malte

Malte Helmert

unread,
Sep 24, 2014, 2:27:38 PM9/24/14
to fast-d...@googlegroups.com
PS: If I remove the two "cout << ..." lines above so that the if/else
blocks work as intended, then the new heuristic works for me:

$ cd src
$ ./build_all
$ ./plan ../benchmarks/blocks/probBLOCKS-4-0.pddl --search 'astar(ss())'
...
Testing SS Heuristic.

Initializing ss heuristic...
...
Solution found!
Actual search time: 0s [t=0s]
...

(This won't work starting from the newest code version, which had some
renamings to do with the upcoming "Task class". I have based this off
revision a38b046fe1e5 instead.)

Malte Helmert

unread,
Sep 24, 2014, 2:33:01 PM9/24/14
to fast-d...@googlegroups.com
On 24.09.2014 19:34, Marvin Abisrror wrote:
> Hello,
>
> I have copied and pasted with another name the files
> goal_count_heuristic.{h,cc} and modified the file Makefile in the
> /search directory, but
> after testing I get an error message.
>
> I was wondering if should I compile in some way the file Makefile in
> order to recognize my changes.

Ah, maybe I misunderstood this question, because the output you got
matches what happens if your code isn't compiled and you're working with
the original unmodified Fast Downward code. (For example, the compiling
step should show the if/else syntax error.)

You don't have to compile the *Makefile*, but you do have to compile the
*code* by running "make". If you did that, then perhaps the problem is
that the change you made to the Makefile wasn't correct, in which case
it might help if you could send us a diff for the Makefile.

Cheers,
Malte

Marvin Abisrror

unread,
Sep 24, 2014, 2:38:34 PM9/24/14
to fast-d...@googlegroups.com
It is the same code of goal_count_heuristic{cc, h}.
I have copied and pasted with the name ss_heuristic{cc,h} in the same directory.

About the fix of gabi, I have tried and I continue having the same error.
And about the if/else they are indented and has the same as goal_count_heuristic.cc

I am attaching the Makefile (.txt I have changed the extension to upload.), please note that it is added with the name ss_heuristic.h under
the file goal_count_heuristic.h

Also, I have tested the heuristic goalcount and it is working fine.

Cheers.
Makefile.txt

Malte Helmert

unread,
Sep 24, 2014, 2:50:39 PM9/24/14
to fast-d...@googlegroups.com
On 24.09.2014 20:38, Marvin Abisrror wrote:
> It is the same code of goal_count_heuristic{cc, h}.

Hi Marvin,

it is not quite the same code. As I wrote, your code includes the
additional lines

cout<<"goal uno"<<"\n\n";

and
cout<<"SSHeuristic ..."<<"\n\n";

which the goal count heuristic does not include. These are causing
syntax errors (because of the missing braces for the surrounding
if/else). After fixing these syntax errors and compiling the code, your
file works for me.

> About the fix of gabi, I have tried and I continue having the same error.
> And about the if/else they are indented and has the same as
> goal_count_heuristic.cc

Indentation has no meaning in C++. If you have more than one line of
code in an if/else block, you need braces ("{" and "}"). The code in
goal_count_heuristic.cc doesn't need braces because there is only one
line in each if/else block, but you have the additional output lines
there, so the braces are needed.

> I am attaching the Makefile (.txt I have changed the extension to
> upload.), please note that it is added with the name ss_heuristic.h under
> the file goal_count_heuristic.h

The Makefile looks good to me.

If you still cannot reproduce the cause of the problem, I suggest you cd
to the "src" directory, type the following commands and send us the
complete output:

./build_all distclean
./build_all

(It's normal for the "./build_all distclean" output to end with an error
message, so this can be ignored.) This should show the syntax error in
ss_heuristic.cc. If it does not show an error, please continue with the
following line and also send us the output:

./plan ../benchmarks/blocks/probBLOCKS-5-0.pddl --search 'astar(ss())'

Cheers,
Malte

Marvin Abisrror

unread,
Sep 24, 2014, 3:59:42 PM9/24/14
to fast-d...@googlegroups.com
Hello,

I have tested again fixing the issues you mentioned and this is what I get

Dispatcher selected state size 1.
This is a nonunit task.

I have attached the scripts ss_heuristic.{cc,h} again.

Regards.
ss_heuristic.cc
ss_heuristic.h

Malte Helmert

unread,
Sep 24, 2014, 4:09:10 PM9/24/14
to fast-d...@googlegroups.com
On 24.09.2014 21:59, Marvin Abisrror wrote:
> Hello,
>
> I have tested again fixing the issues you mentioned and this is what I get
>
> Dispatcher selected state size 1.
> This is a nonunit task.
>
> I have attached the scripts ss_heuristic.{cc,h} again.
>
> Regards.

Hi again,

this looks like the actual planner isn't started, but we really need
more information. In my previous email, I asked for the complete output
of the three commands I mentioned. Can you send them, copied-and-pasted
from your shell, together with the commands that you typed? Also, which
operating system are you working with?

Cheers,
Malte
> --
> You received this message because you are subscribed to the Google
> Groups "Fast Downward" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to fast-downwar...@googlegroups.com
> <mailto:fast-downwar...@googlegroups.com>.

Marvin Abisrror

unread,
Sep 25, 2014, 10:38:14 AM9/25/14
to fast-d...@googlegroups.com
Good Morning Malte,

I am working with a cluster in a linux enviroment and basically what I am
doing is to create the script .sh with the three process of fast downward and
executing it in this way: qsub A1.sh

I have attached the files .sh and the result of that execution using ss() heuristic
and the domain-problem you mentioned.

Also, I have done the same steps in a fast downward in my machine and the results
are the same.

I do not know what I am doing wrong.

Regards.
A1.sh
Astarblocks1.txt

Malte Helmert

unread,
Sep 25, 2014, 3:32:04 PM9/25/14
to fast-d...@googlegroups.com
On 25.09.2014 16:38, Marvin Abisrror wrote:
> Good Morning Malte,
>
> I am working with a cluster in a linux enviroment and basically what I am
> doing is to create the script .sh with the three process of fast
> downward and
> executing it in this way: qsub A1.sh
>
> I have attached the files .sh and the result of that execution using
> ss() heuristic
> and the domain-problem you mentioned.
>
> Also, I have done the same steps in a fast downward in my machine and
> the results
> are the same.
>
> I do not know what I am doing wrong.
>
> Regards.

Hi Marvin,

sorry if this is a stupid question, but from the path names in your
shell script and the ufv.br domain mentioned in the file, am I correct
in guessing that you work together with Levi Lelis? If yes, maybe it
could help to also get Levi involved in the discussion. (We can also
move the discussion off the list -- just reply to this email address
instead of the list.)


I suggest we get this to work on your local machine before worrying
about the cluster (qsub) environment because the cluster adds additional
sources of error.

I'm sorry to be repeating myself, but you're not sending us all the
information we need. :-) So let me try again. We need the *full shell
transcript* (showing your commands and all outputs) for *all* the
following commands, executed in sequence:

# Go to the base directory of the repository.
cd src
./build_all distclean
./build_all
./plan ../benchmarks/blocks/probBLOCKS-5-0.pddl --search 'astar(ss())'

So far, we still haven't seen any output from the build step, and
without this we cannot see what is going on.

Cheers,
Malte
Reply all
Reply to author
Forward
0 new messages