Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trace file format #209

Closed
aymeric75 opened this issue Dec 14, 2024 · 5 comments
Closed

trace file format #209

aymeric75 opened this issue Dec 14, 2024 · 5 comments
Assignees
Labels
documentation Improvements or additions to documentation generation-technique New model generation technique to implement question Further information is requested

Comments

@aymeric75
Copy link

Hello,

I have a file trace where each line is alternatively a state (a 50 bits vector) then an action (an integer) etc, like so:

0 0 0 0 0 0 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 1 1 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0
0
0 0 0 1 0 0 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 1 1 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0
1

Is there an easy way to use (or convert) this file with Macq ?

Regards

@haz
Copy link
Contributor

haz commented Dec 14, 2024

So there currently isn't a full support for this format, but it should be a great example of how to use the library (small wrapper should do the trick). I can whip something up for you.

Can you elaborate on what else you might have? Name for the fluents / actions, for example?

@haz haz self-assigned this Dec 14, 2024
@haz haz added documentation Improvements or additions to documentation question Further information is requested labels Dec 14, 2024
@aymeric75
Copy link
Author

Thanks Christian

Names of the actions: a0, a1 ... up to a21

Names of the fluents: z0, z1 ... up to z49

The actions are actually grounded actions (with grounded effects and preconditions), for instance, here, since I am working on Tower of Hanoi images, a0 would be move(d1, d2)

The fluents are only propositional variables, because I work with the latent values of a discrete VAE (from Latplan)

Regards

@haz haz added the generation-technique New model generation technique to implement label Dec 17, 2024
@haz
Copy link
Contributor

haz commented Dec 19, 2024

Ah, good ol latplan...

So what you're after is pretty much already there. Give this script a try:

from macq.generate.csv import load as load_traces_from_csv

data = """

plan_id,action,z0,z1,z2
1,a0,1,0,1
1,a1,0,1,0

""".strip()

with open("test.csv", "w") as f:
    f.write(data)

td = load_traces_from_csv("test.csv", "action", "plan_id")
td.print()

The plan_id lets you have different sequences of actions/states (i.e., multiple traces). If you have just one, then feel free to just use the same index for all the rows.

@haz
Copy link
Contributor

haz commented Dec 21, 2024

Did this work for you, @aymeric75 ?

@haz
Copy link
Contributor

haz commented Dec 24, 2024

Marking closed, as I think this is readily handled with the code snippet above

@haz haz closed this as completed Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation generation-technique New model generation technique to implement question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants