repo stringlengths 2 99 | file stringlengths 13 225 | code stringlengths 0 18.3M | file_length int64 0 18.3M | avg_line_length float64 0 1.36M | max_line_length int64 0 4.26M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
hyperopt | hyperopt-master/hyperopt/pyll/base.py | # file is called AST to not collide with std lib module 'ast'
#
# It provides types to build ASTs in a simple lambda-notation style
#
from future import standard_library
import copy
import logging
import operator
import time
from collections import deque
import networkx as nx
# TODO: move things depending on numpy (... | 35,322 | 30.482175 | 87 | py |
hyperopt | hyperopt-master/hyperopt/pyll/stochastic.py | """
Constructs for annotating base graphs.
"""
from past.utils import old_div
import sys
import numpy as np
from .base import scope, as_apply, dfs, rec_eval, clone
################################################################################
##########################################################################... | 4,886 | 22.382775 | 86 | py |
hyperopt | hyperopt-master/hyperopt/pyll/__init__.py | from .base import Apply
from .base import Literal
from .base import as_apply
from .base import scope
from .base import rec_eval
from .base import clone
from .base import clone_merge
from .base import dfs
from .base import toposort
# -- adds symbols to scope
from . import stochastic
| 284 | 20.923077 | 29 | py |
hyperopt | hyperopt-master/hyperopt/pyll/tests/test_stochastic.py | from past.utils import old_div
import numpy as np
from hyperopt.pyll import scope, as_apply, rec_eval
from hyperopt.pyll.stochastic import recursive_set_rng_kwarg, sample
def test_recursive_set_rng_kwarg():
uniform = scope.uniform
a = as_apply([uniform(0, 1), uniform(2, 3)])
rng = np.random.default_rng(23... | 2,054 | 27.150685 | 85 | py |
hyperopt | hyperopt-master/hyperopt/pyll/tests/__init__.py | 0 | 0 | 0 | py | |
hyperopt | hyperopt-master/hyperopt/pyll/tests/test_base.py | from hyperopt.pyll import base
from hyperopt.pyll.base import (
Literal,
as_apply,
Apply,
dfs,
scope,
rec_eval,
p0,
Lambda,
clone_merge,
)
from nose import SkipTest
from nose.tools import assert_raises
import numpy as np
def test_literal_pprint():
l = Literal(5)
print(str(... | 7,634 | 24.535117 | 75 | py |
hyperopt | hyperopt-master/hyperopt/tests/__init__.py | 0 | 0 | 0 | py | |
hyperopt | hyperopt-master/hyperopt/tests/test_base.py | import copy
import unittest
import numpy as np
import bson
from hyperopt.pyll import scope
from hyperopt.base import JOB_STATE_DONE, JOB_STATE_NEW
from hyperopt.base import TRIAL_KEYS
from hyperopt.base import TRIAL_MISC_KEYS
from hyperopt.base import InvalidTrial
from hyperopt.base import miscs_to_idxs_vals
from hyp... | 8,032 | 30.625984 | 88 | py |
hyperopt | hyperopt-master/hyperopt/tests/unit/test_tpe.py | from past.utils import old_div
from functools import partial
import os
import unittest
import nose
import numpy as np
try:
import matplotlib.pyplot as plt
except ImportError:
pass
from hyperopt import pyll
from hyperopt.pyll import scope
from hyperopt import Trials
from hyperopt.base import miscs_to_idxs_... | 23,101 | 28.429299 | 88 | py |
hyperopt | hyperopt-master/hyperopt/tests/unit/test_webpage.py | def test_landing_screen():
# define an objective function
def objective(args):
case, val = args
if case == "case 1":
return val
else:
return val**2
# define a search space
from hyperopt import hp
space = hp.choice(
"a",
[
... | 729 | 22.548387 | 84 | py |
hyperopt | hyperopt-master/hyperopt/tests/unit/test_vectorize.py | import numpy as np
from hyperopt.pyll import as_apply, scope, rec_eval, clone, dfs
from hyperopt.pyll.stochastic import recursive_set_rng_kwarg
from hyperopt import base, fmin, rand
from hyperopt.vectorize import VectorizeHelper
from hyperopt.vectorize import replace_repeat_stochastic
from hyperopt.pyll_utils import ... | 7,597 | 26.729927 | 85 | py |
hyperopt | hyperopt-master/hyperopt/tests/unit/test_plotting.py | """
Verify that the plotting routines can at least run.
If environment variable HYPEROPT_SHOW is defined and true,
then the plots actually appear.
"""
import unittest
import os
try:
import matplotlib
matplotlib.use("svg") # -- prevents trying to connect to X server
except ImportError:
import nose
... | 1,220 | 22.480769 | 81 | py |
hyperopt | hyperopt-master/hyperopt/tests/unit/test_rand.py | import unittest
from hyperopt.base import Trials, trials_from_docs, miscs_to_idxs_vals
from hyperopt import rand
from hyperopt.tests.test_base import Suggest_API
from .test_domains import gauss_wave2, coin_flip
import numpy as np
TestRand = Suggest_API.make_tst_class(rand.suggest, gauss_wave2(), "TestRand")
class Te... | 959 | 33.285714 | 78 | py |
hyperopt | hyperopt-master/hyperopt/tests/unit/test_anneal.py | from functools import partial
import unittest
import numpy as np
from hyperopt import anneal
from hyperopt import rand
from hyperopt import Trials, fmin
try:
import matplotlib.pyplot as plt
except ImportError:
plt = None
from .test_domains import CasePerDomain
def passthrough(x):
return x
class TestI... | 2,273 | 23.451613 | 69 | py |
hyperopt | hyperopt-master/hyperopt/tests/unit/test_atpe_basic.py | import random
import numpy as np
from hyperopt import hp, fmin, atpe, space_eval
random.seed(1)
np.random.seed(1)
def test_run_basic_search():
def objective(args):
case, val = args
if case == "case 1":
return val
else:
return val**2
# define a search space
... | 859 | 21.631579 | 104 | py |
hyperopt | hyperopt-master/hyperopt/tests/unit/test_ipy.py | """
To use this test script, there should be a cluster of ipython parallel engines
instantiated already. Their working directory should be the current
directory: hyperopt/tests
To start the engines in hyperopt/hyperopt/tests/
use: $ ipcluster start --n=2
"""
import sys
from nose import SkipTest
try:
from IPyt... | 2,061 | 22.701149 | 78 | py |
hyperopt | hyperopt-master/hyperopt/tests/unit/test_randint.py | import unittest
from functools import partial
import numpy as np
from hyperopt import hp, Trials, fmin, rand, tpe
import hyperopt.pyll.stochastic
def test_basic():
space = hp.randint("a", 5)
x = np.zeros(5)
rng = np.random.default_rng(123)
for i in range(0, 1000):
nesto = hyperopt.pyll.stocha... | 3,332 | 29.027027 | 82 | py |
hyperopt | hyperopt-master/hyperopt/tests/unit/test_rdists.py | from past.utils import old_div
from collections import defaultdict
import unittest
import numpy as np
import numpy.testing as npt
from hyperopt.rdists import (
loguniform_gen,
lognorm_gen,
quniform_gen,
qloguniform_gen,
qnormal_gen,
qlognormal_gen,
)
from scipy import stats
from scipy.stats.tes... | 8,714 | 29.578947 | 79 | py |
hyperopt | hyperopt-master/hyperopt/tests/unit/__init__.py | 0 | 0 | 0 | py | |
hyperopt | hyperopt-master/hyperopt/tests/unit/test_domains.py | from past.utils import old_div
import unittest
import numpy as np
from hyperopt import Trials, Domain, fmin, hp, base
from hyperopt.rand import suggest
from hyperopt.pyll import as_apply
from hyperopt.pyll import scope
# -- define this bandit here too for completeness' sake
def domain_constructor(**b_kwargs):
"... | 8,728 | 27.067524 | 85 | py |
hyperopt | hyperopt-master/hyperopt/tests/unit/test_pyll_utils.py | from hyperopt import pyll_utils
from hyperopt.pyll_utils import EQ
from hyperopt.pyll_utils import expr_to_config
from hyperopt import hp
from hyperopt.pyll import as_apply
from hyperopt.pyll.stochastic import sample
import unittest
import numpy as np
import pytest
def test_expr_to_config():
z = hp.randint("z", 1... | 4,559 | 31.571429 | 85 | py |
hyperopt | hyperopt-master/hyperopt/tests/unit/test_criteria.py | from past.utils import old_div
import numpy as np
import hyperopt.criteria as crit
def test_ei():
rng = np.random.default_rng(123)
for mean, var in [(0, 1), (-4, 9)]:
thresholds = np.arange(-5, 5, 0.25) * np.sqrt(var) + mean
v_n = [
crit.EI_gaussian_empirical(mean, var, thresh, rn... | 1,994 | 28.338235 | 87 | py |
hyperopt | hyperopt-master/hyperopt/tests/unit/test_fmin.py | import unittest
import numpy as np
from timeit import default_timer as timer
import time
from hyperopt.early_stop import no_progress_loss
from hyperopt.fmin import generate_trials_to_calculate
import pytest
from hyperopt import (
fmin,
rand,
tpe,
hp,
Trials,
exceptions,
space_eval,
STAT... | 10,176 | 24.764557 | 110 | py |
hyperopt | hyperopt-master/hyperopt/tests/unit/test_pchoice.py | from functools import partial
import numpy as np
import unittest
from hyperopt import hp, Trials, fmin, tpe, anneal, rand
import hyperopt.pyll.stochastic
class TestPChoice(unittest.TestCase):
def test_basic(self):
space = hp.pchoice(
"naive_type",
[(0.14, "gaussian"), (0.02, "multi... | 5,341 | 27.566845 | 85 | py |
hyperopt | hyperopt-master/hyperopt/tests/unit/test_progress.py | import sys
from hyperopt.progress import tqdm_progress_callback
def test_tqdm_progress_callback_restores_stdout():
real_stdout = sys.stdout
with tqdm_progress_callback(initial=0, total=100) as ctx:
assert sys.stdout != real_stdout
ctx.postfix = "best loss: 4711"
ctx.update(42)
ass... | 350 | 26 | 61 | py |
hyperopt | hyperopt-master/hyperopt/tests/unit/test_utils.py | import numpy as np
from nose.tools import raises, eq_
import shutil
import os
from hyperopt.utils import fast_isin
from hyperopt.utils import get_most_recent_inds
from hyperopt.utils import temp_dir, working_dir, get_closest_dir, path_split_all
def test_fast_isin():
Y = np.random.randint(0, 10000, size=(100,))
... | 4,546 | 27.778481 | 82 | py |
hyperopt | hyperopt-master/hyperopt/tests/integration/test_mongoexp.py | import pickle as pickle
import os
import signal
import subprocess
import sys
import traceback
import threading
import time
import unittest
import numpy as np
import nose
import nose.plugins.skip
from hyperopt.base import JOB_STATE_DONE, STATUS_OK
from hyperopt.mongoexp import parse_url
from hyperopt.mongoexp import M... | 14,327 | 29.355932 | 88 | py |
hyperopt | hyperopt-master/hyperopt/tests/integration/test_sklearn.py | """Test scikit-learn integration."""
import pytest
from sklearn.linear_model import Ridge, RidgeClassifier
from sklearn.utils.estimator_checks import check_estimator
from hyperopt import hp
from hyperopt.sklearn import HyperoptSearchCV
@pytest.mark.parametrize(
"estimator,check",
list(
check_estimat... | 2,229 | 33.307692 | 105 | py |
hyperopt | hyperopt-master/hyperopt/tests/integration/test_spark.py | import contextlib
import logging
import os
import shutil
import tempfile
import time
import timeit
import unittest
import numpy as np
from pyspark.sql import SparkSession
from io import StringIO
from hyperopt import SparkTrials, anneal, base, fmin, hp, rand
from hyperopt.tests.unit.test_fmin import test_quadratic1_t... | 21,662 | 33.996769 | 106 | py |
hyperopt | hyperopt-master/hyperopt/tests/integration/__init__.py | 0 | 0 | 0 | py | |
DAAISy | DAAISy-main/learn_model.py | #!/usr/local/bin/python3
# encoding: utf-8
import os
import numpy as np
import time
import csv
import math
from src.lattice import *
from itertools import product
from src.utils import parse_files
from src.agent import Agent
from src.model_drift import plot
from src.model_drift import PATuple
from src.model_drift im... | 29,709 | 58.658635 | 405 | py |
DAAISy | DAAISy-main/config.py | #!/usr/local/bin/python3
# encoding: utf-8
domains = ["blocksworld","gripper","miconic","satellite","rovers","termes"]
drifted_domain_file = "domain.pddl" # IPC domain
regenerate_random_states = False
# Computed automatically in generate_random_init_domains.py and learn_model.py
domain_to_total_pals, domain_to_total_... | 1,654 | 67.958333 | 157 | py |
DAAISy | DAAISy-main/__init__.py | 0 | 0 | 0 | py | |
DAAISy | DAAISy-main/generate_random_init_domains.py | #!/usr/local/bin/python3
# encoding: utf-8
import random
import copy
import math
import time
from itertools import product
import sys
from src.config import *
from src.utils.translate import pddl_parser
import config
seed = int(time.time())
random.seed(seed)
print("Using {} as random seed..".format(seed))
INFO_STRIN... | 19,814 | 48.168734 | 363 | py |
DAAISy | DAAISy-main/dependencies/__init__.py | 0 | 0 | 0 | py | |
DAAISy | DAAISy-main/dependencies/fama/__init__.py | 0 | 0 | 0 | py | |
DAAISy | DAAISy-main/dependencies/fama/src/compiler3.py | #! /usr/bin/env python
import glob, os, sys, copy, itertools
import pddl, pddl_parser
import config, fdtask_to_pddl
def get_all_types(task, itype):
output=[itype]
# for i in task.types:
# if itype in i.name:
# if i.basetype_name!="object":
# output = output + [str(i.basetype_name)]
... | 30,587 | 42.021097 | 222 | py |
DAAISy | DAAISy-main/dependencies/fama/src/experimenter_FAMA.py | #! /usr/bin/env python
import glob, os, sys, copy, itertools, math, time
import pddl, pddl_parser
import fdtask_to_pddl
import numpy as np
import model_evaluator
import config
# **************************************#
# MAIN
# **************************************#
try:
if "-s" in sys.argv:
index = sys.a... | 4,360 | 28.268456 | 272 | py |
DAAISy | DAAISy-main/dependencies/fama/src/FAMA.py | #! /usr/bin/env python
import glob, os, sys, copy, itertools
import pddl, pddl_parser
import config, fdtask_to_pddl
import numpy as np
def get_max_vars(actions):
max_vars = 0
for a in actions:
max_vars = max(max_vars, a.num_external_parameters)
return max_vars
def get_max_steps(traces):
trace... | 54,118 | 44.25 | 345 | py |
DAAISy | DAAISy-main/dependencies/fama/src/aij18generator.py | #! /usr/bin/env python
import sys,glob,os
import pddl, pddl_parser
import config, fdtask_to_pddl
# **************************************#
# MAIN
# **************************************#
try:
source_folder_name = sys.argv[1]
destination_folder_name = sys.argv[2]
except:
print "Usage:"
print sys.arg... | 2,763 | 35.853333 | 138 | py |
DAAISy | DAAISy-main/dependencies/fama/src/compiler_new.py | #! /usr/bin/env python
import glob, os, sys, copy, itertools
import pddl, pddl_parser
import config, fdtask_to_pddl
import numpy as np
def get_max_vars(actions):
max_vars = 0
for a in actions:
max_vars = max(max_vars, a.num_external_parameters)
return max_vars
def get_max_steps(traces):
trace... | 43,617 | 43.782341 | 345 | py |
DAAISy | DAAISy-main/dependencies/fama/src/fdtask_to_pddl.py | import sys
import utils,pddl
def format_problem(task,domain):
str_out = "(define (problem " + task.task_name + ")\n"
str_out = str_out + " (:domain "+ task.domain_name + ")\n"
str_out = str_out + " (:objects "
for i in set(task.objects):
str_out = str_out + str(i).replace(":"," - ") + " "
s... | 4,449 | 30.560284 | 123 | py |
DAAISy | DAAISy-main/dependencies/fama/src/tim.py | #! /usr/bin/env python
import pddl_parser
import sys
import itertools
def build_property_map(task):
properties = dict()
counter = 0
for predicate in task.predicates:
#if predicate.name != "=":
for i in range(1, len(predicate.arguments)+1):
key = "{}_{}".format(predicate.name, i... | 29,768 | 38.221344 | 164 | py |
DAAISy | DAAISy-main/dependencies/fama/src/compiler2.py | #! /usr/bin/env python
import glob, os, sys, copy, itertools
import pddl, pddl_parser
import config, fdtask_to_pddl
def get_all_types(task, itype):
output=[itype]
# for i in task.types:
# if itype in i.name:
# if i.basetype_name!="object":
# output = output + [str(i.basetype_name)]
... | 35,360 | 43.20125 | 347 | py |
DAAISy | DAAISy-main/dependencies/fama/src/FAMA_FSM.py | #! /usr/bin/env python
import glob, os, sys, copy, itertools
import pddl, pddl_parser
import config, fdtask_to_pddl
import numpy as np
def get_max_vars(actions):
max_vars = 0
for a in actions:
max_vars = max(max_vars, a.num_external_parameters)
return max_vars
def get_max_steps(traces):
trace... | 30,816 | 40.985014 | 272 | py |
DAAISy | DAAISy-main/dependencies/fama/src/cleanup.py | #! /usr/bin/env python
import sys,os
cmd= "rm -rf *.pyc pddl/*.pyc pddl_parser/*.pyc *.*~ test-* plan-* aux_* output* *.log sas* learned_domain.pddl results/*"
print cmd
os.system(cmd)
sys.exit(0)
| 202 | 19.3 | 124 | py |
DAAISy | DAAISy-main/dependencies/fama/src/model_evaluator.py | #! /usr/bin/env python
# from __future__ import division
import sys
import pddl, pddl_parser
import numpy as np
import itertools
def reform_literal(literal, action_args, reformulation):
literal_name = literal.predicate
params = [action_args[reformulation[action_args.index(arg)]-1] for arg in literal.args]
... | 11,499 | 44.098039 | 193 | py |
DAAISy | DAAISy-main/dependencies/fama/src/meta-example-generator.py | #! /usr/bin/env python
import sys, os, glob
import pddl, pddl_parser
import fdtask_to_pddl, planning
#**************************************#
# MAIN
#**************************************#
try:
source_folder_name = sys.argv[1]
destination_folder_name = sys.argv[2]
except:
print "Usage:"
print sys.ar... | 3,395 | 46.166667 | 133 | py |
DAAISy | DAAISy-main/dependencies/fama/src/utils.py | #! /usr/bin/env python
import pddl
def compute_constants(task,domain):
constants=set()
for i in range(0,len(domain)):
if domain [i][0]==":constants":
btype=False
for c in domain[i][1:]:
if c=="-":
btype=True
elif btype==False:
io=[o.n... | 2,611 | 24.607843 | 78 | py |
DAAISy | DAAISy-main/dependencies/fama/src/testset-evaluator.py | #! /usr/bin/env python
import glob, os, sys, copy, itertools, math
import pddl, pddl_parser
import config, fdtask_to_pddl
def get_all_types(task, itype):
output=[itype]
for t in task.types:
if t.basetype_name == itype:
output.append(str(t.name))
return output
def get_max_steps_from_plans(p... | 20,969 | 40.772908 | 252 | py |
DAAISy | DAAISy-main/dependencies/fama/src/planning.py | #! /usr/bin/env python
import sys, os, copy
from dependencies.fama.src import pddl, pddl_parser
from dependencies.fama.src import config
class Literal:
def __init__(self, n, ags):
self.name = n
self.args = ags
def __str__(self):
return "("+self.name +" " + " ".join(self.args)+"... | 6,709 | 31.259615 | 146 | py |
DAAISy | DAAISy-main/dependencies/fama/src/graph.py | #! /usr/bin/env python
from __future__ import print_function
class Graph:
def __init__(self, nodes):
self.nodes = nodes
self.neighbours = dict((u, set()) for u in nodes)
def connect(self, u, v):
self.neighbours[u].add(v)
self.neighbours[v].add(u)
def connected_components(se... | 1,345 | 27.638298 | 82 | py |
DAAISy | DAAISy-main/dependencies/fama/src/example-generator.py | #! /usr/bin/env python
import sys, os, copy, glob, itertools
import pddl, pddl_parser
import fdtask_to_pddl, planning
import config
import fileinput
import copy
# Madagascar details
M_PATH=config.PLANNER_PATH
M_CALL="/"+config.PLANNER_NAME
M_PARAMS=" -W " + config.PLANNER_PARAMS
# FD details
FD_PATH="/home/slimbook/s... | 9,545 | 32.97153 | 177 | py |
DAAISy | DAAISy-main/dependencies/fama/src/walk-generator.py | #! /usr/bin/env python
import sys, os, copy, glob, itertools, random
import pddl, pddl_parser
import fdtask_to_pddl, planning
import config
# Madagascar details
M_PATH=config.PLANNER_PATH
M_CALL="/"+config.PLANNER_NAME
M_PARAMS=" -W " + config.PLANNER_PARAMS
# FD details
FD_PATH="/home/slimbook/software/fd/"
FD_CALL... | 8,022 | 34.5 | 166 | py |
DAAISy | DAAISy-main/dependencies/fama/src/config.py | #! /usr/bin/env python2
import os
DOMAIN = "blocks_rash"
ROOT_PATH = os.getcwd()+"/dependencies/"
PROJECT_PATH = ROOT_PATH+"fama"
COUNTER = 140
OUTPUT_PATH = PROJECT_PATH + "/output/" + DOMAIN
PROBLEM_DIR = "/tests"
PLAN_DIR = "/plans"
OBSERVATIONS_DIR = "/observations"
VAL_PATH = ROOT_PATH + "VAL"
VAL_OUT=OUTPUT_P... | 931 | 23.526316 | 64 | py |
DAAISy | DAAISy-main/dependencies/fama/src/compiler.py | #! /usr/bin/env python
import glob, os, sys, copy, itertools
import pddl, pddl_parser
import config, fdtask_to_pddl
def get_all_types(task, itype):
output=[itype]
# for i in task.types:
# if itype in i.name:
# if i.basetype_name!="object":
# output = output + [str(i.basetype_name)]
... | 30,740 | 42.115007 | 222 | py |
DAAISy | DAAISy-main/dependencies/fama/src/evaluator2.py | #! /usr/bin/env python
# from __future__ import division
import sys
import pddl, pddl_parser
import numpy as np
import itertools
def evaluate_matching(matchings, fd_eva_task, fd_ref_task):
ref_pres = set()
eva_pres = set()
ref_adds = set()
eva_adds = set()
ref_dels = set()
eva_dels = set()
... | 7,048 | 37.102703 | 156 | py |
DAAISy | DAAISy-main/dependencies/fama/src/generate_observations.py | """
For computing plans using madagascar, state trajectories using VAL, and observation files
"""
import os, glob
from dependencies.fama.src import planning, pddl, pddl_parser
N_HORIZON = 10
# Can be set/overrided by calling set_paths function and
# providing the domain name, base directory, and example directory
D... | 5,875 | 40.380282 | 159 | py |
DAAISy | DAAISy-main/dependencies/fama/src/unsupervised-evaluator.py | #! /usr/bin/env python
import sys, os, glob
import pddl, pddl_parser
import config, fdtask_to_pddl
#**************************************#
# MAIN
#**************************************#
try:
domain_folder_name = sys.argv[1]
problem_prefix_filename = sys.argv[2]
plan_prefix_filen... | 2,908 | 39.402778 | 170 | py |
DAAISy | DAAISy-main/dependencies/fama/src/__init__.py | 0 | 0 | 0 | py | |
DAAISy | DAAISy-main/dependencies/fama/src/experimenter_new.py | #! /usr/bin/env python
import glob, os, sys, copy, itertools, math, time
import pddl, pddl_parser
import fdtask_to_pddl
import numpy as np
import model_evaluator
import config
# **************************************#
# MAIN
# **************************************#
try:
# print("Command: ", sys.argv)
if "-s"... | 2,866 | 27.107843 | 222 | py |
DAAISy | DAAISy-main/dependencies/fama/src/trace_generator.py | #! /usr/bin/env python
import sys, os, copy, glob, itertools, random
import pddl, pddl_parser
import fdtask_to_pddl, planning
import config
# Madagascar details
M_PATH = config.PLANNER_PATH
M_CALL = "/" + config.PLANNER_NAME
M_PARAMS = " -W " + config.PLANNER_PARAMS
# FD details
FD_PATH = "/home/slimbook/software/fd/... | 3,182 | 31.814433 | 157 | py |
DAAISy | DAAISy-main/dependencies/fama/src/experimenter.py | #! /usr/bin/env python
import glob, os, sys, copy, itertools, math
import pddl, pddl_parser
import fdtask_to_pddl
#**************************************#
# MAIN
#**************************************#
try:
input_level = int(sys.argv[1])
except:
print "Usage:"
print sys.argv[0] + "<input level (0 plans,... | 1,560 | 27.907407 | 158 | py |
DAAISy | DAAISy-main/dependencies/fama/src/pddl/f_expression.py | from __future__ import print_function
class FunctionalExpression(object):
def __init__(self, parts):
self.parts = tuple(parts)
def dump(self, indent=" "):
print("%s%s" % (indent, self._dump()))
for part in self.parts:
part.dump(indent + " ")
def _dump(self):
re... | 3,606 | 39.52809 | 87 | py |
DAAISy | DAAISy-main/dependencies/fama/src/pddl/pddl_types.py | # Renamed from types.py to avoid clash with stdlib module.
# In the future, use explicitly relative imports or absolute
# imports as a better solution.
import itertools
def _get_type_predicate_name(type_name):
# PDDL allows mixing types and predicates, but some PDDL files
# have name collisions between types... | 2,306 | 31.492958 | 76 | py |
DAAISy | DAAISy-main/dependencies/fama/src/pddl/effects.py | from __future__ import print_function
from . import conditions
def cartesian_product(*sequences):
# TODO: Also exists in tools.py outside the pddl package (defined slightly
# differently). Not good. Need proper import paths.
if not sequences:
yield ()
else:
for tup in cartesian_p... | 7,115 | 38.533333 | 97 | py |
DAAISy | DAAISy-main/dependencies/fama/src/pddl/functions.py | class Function(object):
def __init__(self, name, arguments, type_name):
self.name = name
self.arguments = arguments
if type_name != "number":
raise SystemExit("Error: object fluents not supported\n" +
"(function %s has type %s)" % (name, type_name))
... | 550 | 35.733333 | 77 | py |
DAAISy | DAAISy-main/dependencies/fama/src/pddl/actions.py | from __future__ import print_function
import copy
from . import conditions
class Action(object):
def __init__(self, name, parameters, num_external_parameters,
precondition, effects, cost):
assert 0 <= num_external_parameters <= len(parameters)
self.name = name
self.param... | 5,451 | 39.385185 | 95 | py |
DAAISy | DAAISy-main/dependencies/fama/src/pddl/predicates.py | class Predicate(object):
def __init__(self, name, arguments):
self.name = name
self.arguments = arguments
def __str__(self):
return "%s(%s)" % (self.name, ", ".join(map(str, self.arguments)))
def get_arity(self):
return len(self.arguments)
| 286 | 25.090909 | 74 | py |
DAAISy | DAAISy-main/dependencies/fama/src/pddl/__init__.py | from .pddl_types import Type
from .pddl_types import TypedObject
from .tasks import Task
from .tasks import Requirements
from .traces import Trace
from .predicates import Predicate
from .functions import Function
from .actions import Action
from .actions import PropositionalAction
from .axioms import Axiom
from .... | 1,047 | 25.2 | 52 | py |
DAAISy | DAAISy-main/dependencies/fama/src/pddl/tasks.py | from __future__ import print_function
from . import axioms
from . import predicates
class Task(object):
def __init__(self, domain_name, task_name, requirements,
types, objects, predicates, functions, init, goal,
actions, axioms, use_metric):
self.domain_name = domain_nam... | 2,469 | 32.835616 | 74 | py |
DAAISy | DAAISy-main/dependencies/fama/src/pddl/traces.py | from __future__ import print_function
class Trace(object):
def __init__(self, objects, init, goal, actions, states):
self.objects = objects
self.init = init
self.goal = goal
self.actions = actions
self.states = states
def dump(self):
print("Problem %s: %s [%s]" ... | 1,109 | 28.210526 | 65 | py |
DAAISy | DAAISy-main/dependencies/fama/src/pddl/axioms.py | from __future__ import print_function
from . import conditions
class Axiom(object):
def __init__(self, name, parameters, num_external_parameters, condition):
# For an explanation of num_external_parameters, see the
# related Action class. Note that num_external_parameters
# always equals ... | 2,689 | 33.050633 | 88 | py |
DAAISy | DAAISy-main/dependencies/fama/src/pddl/conditions.py | from __future__ import print_function
# Conditions (of any type) are immutable, because they need to
# be hashed occasionally. Immutability also allows more efficient comparison
# based on a precomputed hash value.
#
# Careful: Most other classes (e.g. Effects, Axioms, Actions) are not!
class Condition(object):
... | 11,108 | 36.657627 | 86 | py |
DAAISy | DAAISy-main/dependencies/fama/src/pddl_parser/lisp_parser.py | __all__ = ["ParseError", "parse_nested_list"]
class ParseError(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return self.value
# Basic functions for parsing PDDL (Lisp) files.
def parse_nested_list(input_file):
tokens = tokenize(input_file)
next_token = n... | 1,680 | 31.960784 | 81 | py |
DAAISy | DAAISy-main/dependencies/fama/src/pddl_parser/pddl_file.py | try:
# Python 3.x
from builtins import open as file_open
except ImportError:
# Python 2.x
from codecs import open as file_open
from . import lisp_parser
from . import parsing_functions
def parse_pddl_file(type, filename):
try:
# The builtin open function is shadowed by this module's open ... | 1,330 | 35.972222 | 79 | py |
DAAISy | DAAISy-main/dependencies/fama/src/pddl_parser/__init__.py | from .pddl_file import open
| 28 | 13.5 | 27 | py |
DAAISy | DAAISy-main/dependencies/fama/src/pddl_parser/parsing_functions.py | # -*- coding: utf-8 -*-
from __future__ import print_function
import sys
import copy
import dependencies.fama.src.graph as graph
import dependencies.fama.src.pddl as pddl
import random
import itertools
def parse_typed_list(alist, only_variables=False,
constructor=pddl.TypedObject,
... | 25,474 | 36.027616 | 156 | py |
DAAISy | DAAISy-main/dependencies/fama/src/pddl_parser/pretty_print.py | from __future__ import print_function
import io
import textwrap
__all__ = ["print_nested_list"]
def tokenize_list(obj):
if isinstance(obj, list):
yield "("
for item in obj:
for elem in tokenize_list(item):
yield elem
yield ")"
else:
yield obj
def w... | 1,492 | 26.648148 | 84 | py |
DAAISy | DAAISy-main/dependencies/FD/fast-downward.py | #! /usr/bin/env python3
if __name__ == "__main__":
from driver.main import main
main()
| 96 | 15.166667 | 32 | py |
DAAISy | DAAISy-main/dependencies/FD/build_configs.py | release = ["-DCMAKE_BUILD_TYPE=Release"]
debug = ["-DCMAKE_BUILD_TYPE=Debug"]
releasenolp = ["-DCMAKE_BUILD_TYPE=Release", "-DUSE_LP=NO"]
debugnolp = ["-DCMAKE_BUILD_TYPE=Debug", "-DUSE_LP=NO"]
minimal = ["-DCMAKE_BUILD_TYPE=Release", "-DDISABLE_PLUGINS_BY_DEFAULT=YES"]
DEFAULT = "release"
DEBUG = "debug"
| 308 | 33.333333 | 76 | py |
DAAISy | DAAISy-main/dependencies/FD/build.py | #!/usr/bin/env python3
import errno
import glob
import multiprocessing
import os
import subprocess
import sys
CONFIGS = {}
script_dir = os.path.dirname(__file__)
for config_file in sorted(glob.glob(os.path.join(script_dir, "*build_configs.py"))):
with open(config_file) as f:
config_file_content = f.read()... | 4,963 | 31.233766 | 87 | py |
DAAISy | DAAISy-main/dependencies/FD/src/translate/pddl_to_prolog.py | #! /usr/bin/env python3
import itertools
import normalize
import pddl
import timers
class PrologProgram:
def __init__(self):
self.facts = []
self.rules = []
self.objects = set()
def predicate_name_generator():
for count in itertools.count():
yield "p$%... | 7,436 | 40.316667 | 86 | py |
DAAISy | DAAISy-main/dependencies/FD/src/translate/build_model.py | #! /usr/bin/env python3
import sys
import itertools
import pddl
import timers
from functools import reduce
def convert_rules(prog):
RULE_TYPES = {
"join": JoinRule,
"product": ProductRule,
"project": ProjectRule,
}
result = []
for rule in prog.rules:
RuleType = RU... | 13,114 | 37.125 | 84 | py |
DAAISy | DAAISy-main/dependencies/FD/src/translate/invariant_finder.py | #! /usr/bin/env python3
from collections import deque, defaultdict
import itertools
import time
import invariants
import options
import pddl
import timers
class BalanceChecker:
def __init__(self, task, reachable_action_params):
self.predicates_to_add_actions = defaultdict(set)
self.action_to_hea... | 6,100 | 38.875817 | 84 | py |
DAAISy | DAAISy-main/dependencies/FD/src/translate/split_rules.py | # split_rules: Split rules whose conditions fall into different "connected
# components" (where to conditions are related if they share a variabe) into
# several rules, one for each connected component and one high-level rule.
from pddl_to_prolog import Rule, get_variables
import graph
import greedy_join
import pddl
... | 2,569 | 36.246377 | 78 | py |
DAAISy | DAAISy-main/dependencies/FD/src/translate/variable_order.py | from collections import defaultdict, deque
from itertools import chain
import heapq
import sccs
DEBUG = False
class CausalGraph:
"""Weighted causal graph used for defining a variable order.
The causal graph only contains pre->eff edges (in contrast to the
variant that also has eff<->eff edges).
The... | 11,601 | 39.708772 | 81 | py |
DAAISy | DAAISy-main/dependencies/FD/src/translate/axiom_rules.py | import options
import pddl
import sccs
import timers
from collections import defaultdict
from itertools import chain
DEBUG = False
class AxiomDependencies(object):
def __init__(self, axioms):
if DEBUG:
assert all(isinstance(axiom.effect, pddl.Atom) for axiom in axioms)
self.derived_v... | 15,777 | 41.187166 | 143 | py |
DAAISy | DAAISy-main/dependencies/FD/src/translate/translate.py | #! /usr/bin/env python3
import os
import sys
import traceback
def python_version_supported():
return sys.version_info >= (3, 6)
if not python_version_supported():
sys.exit("Error: Translator only supports Python >= 3.6.")
from collections import defaultdict
from copy import deepcopy
from itertools import ... | 30,991 | 41.108696 | 85 | py |
DAAISy | DAAISy-main/dependencies/FD/src/translate/graph.py | #! /usr/bin/env python3
class Graph:
def __init__(self, nodes):
self.nodes = nodes
self.neighbours = {u: set() for u in nodes}
def connect(self, u, v):
self.neighbours[u].add(v)
self.neighbours[v].add(u)
def connected_components(self):
remaining_nodes = set(self.nod... | 1,296 | 27.195652 | 82 | py |
DAAISy | DAAISy-main/dependencies/FD/src/translate/fact_groups.py | import invariant_finder
import options
import pddl
import timers
DEBUG = False
def expand_group(group, task, reachable_facts):
result = []
for fact in group:
try:
pos = list(fact.args).index("?X")
except ValueError:
result.append(fact)
else:
# NOTE... | 4,698 | 34.598485 | 86 | py |
DAAISy | DAAISy-main/dependencies/FD/src/translate/timers.py | import contextlib
import os
import sys
import time
class Timer:
def __init__(self):
self.start_time = time.time()
self.start_clock = self._clock()
def _clock(self):
times = os.times()
return times[0] + times[1]
def __str__(self):
return "[%.3fs CPU, %.3fs wall-clo... | 732 | 19.361111 | 50 | py |
DAAISy | DAAISy-main/dependencies/FD/src/translate/tools.py | def cartesian_product(sequences):
# TODO: Rename this. It's not good that we have two functions
# called "product" and "cartesian_product", of which "product"
# computes cartesian products, while "cartesian_product" does not.
# This isn't actually a proper cartesian product because we
# concatenate... | 1,127 | 35.387097 | 74 | py |
DAAISy | DAAISy-main/dependencies/FD/src/translate/options.py | import argparse
import sys
def parse_args():
argparser = argparse.ArgumentParser()
argparser.add_argument(
"domain", help="path to domain pddl file")
argparser.add_argument(
"task", help="path to task pddl file")
argparser.add_argument(
"--relaxed", dest="generate_relaxed_task"... | 3,176 | 41.36 | 89 | py |
DAAISy | DAAISy-main/dependencies/FD/src/translate/simplify.py | """This module contains a function for simplifying tasks in
finite-domain representation (SASTask). Usage:
simplify.filter_unreachable_propositions(sas_task)
simplifies `sas_task` in-place. If simplification detects that the
task is unsolvable, the function raises `simplify.Impossible`. If it
detects that is has ... | 20,146 | 37.669866 | 80 | py |
DAAISy | DAAISy-main/dependencies/FD/src/translate/constraints.py | import itertools
class NegativeClause:
# disjunction of inequalities
def __init__(self, parts):
self.parts = parts
assert len(parts)
def __str__(self):
disj = " or ".join(["(%s != %s)" % (v1, v2)
for (v1, v2) in self.parts])
return "(%s)" % disj
... | 5,589 | 33.720497 | 79 | py |
DAAISy | DAAISy-main/dependencies/FD/src/translate/invariants.py | from collections import defaultdict
import itertools
import constraints
import pddl
import tools
# Notes:
# All parts of an invariant always use all non-counted variables
# -> the arity of all predicates covered by an invariant is either the
# number of the invariant variables or this value + 1
#
# we currently keep ... | 17,202 | 40.55314 | 94 | py |
DAAISy | DAAISy-main/dependencies/FD/src/translate/greedy_join.py | import sys
import pddl
import pddl_to_prolog
class OccurrencesTracker:
"""Keeps track of the number of times each variable appears
in a list of symbolic atoms."""
def __init__(self, rule):
self.occurrences = {}
self.update(rule.effect, +1)
for cond in rule.conditions:
s... | 4,347 | 38.171171 | 88 | py |
DAAISy | DAAISy-main/dependencies/FD/src/translate/instantiate.py | #! /usr/bin/env python3
from collections import defaultdict
import build_model
import pddl_to_prolog
import pddl
import timers
def get_fluent_facts(task, model):
fluent_predicates = set()
for action in task.actions:
for effect in action.effects:
fluent_predicates.add(effect.literal.predi... | 3,722 | 34.798077 | 86 | py |
DAAISy | DAAISy-main/dependencies/FD/src/translate/normalize.py | #! /usr/bin/env python3
import copy
import pddl
class ConditionProxy:
def clone_owner(self):
clone = copy.copy(self)
clone.owner = copy.copy(clone.owner)
return clone
class PreconditionProxy(ConditionProxy):
def __init__(self, action):
self.owner = action
self.conditi... | 16,121 | 39.507538 | 90 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.