aiplan4eu / unified-planning

The AIPlan4EU Unified Planning Library
Apache License 2.0
194 stars 41 forks source link

How clear the UP envrionment before each planning task? #478

Open MFaisalZaki opened 1 year ago

MFaisalZaki commented 1 year ago

How to clear the environment after each loop to avoid having this error: Screenshot from 2023-08-22 15-54-15

All that I do is iterate on a dictionary containing planning problems:

for planning_task in planning_tasks:
        _planning_task = PDDLReader(None).parse_problem(planning_task['domain'], planning_task['problem'])

I tried disabling the flag using the following:

up.shortcuts.get_environment().error_used_named = True

and the script stopped running.

alvalentini commented 1 year ago

@MFaisalZaki can you attach the PDDL files?

MFaisalZaki commented 1 year ago

Sure, here are the files. freecell-strips-typed.zip

alvalentini commented 1 year ago

Try with this code:

from unified_planning.shortcuts import get_environment
get_environment().error_used_name = False
alvalentini commented 1 year ago

@MFaisalZaki Does it solve your problem?

MFaisalZaki commented 1 year ago

@alvalentini sorry I did not have time to check it, but I plan to check your suggestion this week, and I'll keep you posted.

MFaisalZaki commented 1 year ago

@alvalentini, sorry for the late reply. Yeah, this flag works.

MFaisalZaki commented 5 months ago

Hi @alvalentini,

I'm sorry for reopening this issue again. But I still get this error even after setting the flag to False.

from unified_planning.io import PDDLReader
from unified_planning.shortcuts import *

up.shortcuts.get_environment().error_used_name = False

domainfile = 'domain.pddl'
problemfile = 'problem.pddl'

task = PDDLReader().parse_problem(domainfile, problemfile)

bug

Here are the files to reproduce: bug.zip

Thanks.

alvalentini commented 4 months ago

Hi @MFaisalZaki! In this case you have the name p3 used for multiple Objects. This is not allowed even if you set the flag error_used_name to False.

With the flag set to False is only possible to use the same name for different elements of the problem (e.g. an Object and an Action).