scipplan 0.1.0a0__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. scipplan/__init__.py +5 -0
  2. scipplan/config.py +152 -0
  3. scipplan/helpers.py +30 -0
  4. scipplan/parse_model.py +275 -0
  5. scipplan/plan_model.py +257 -0
  6. scipplan/scipplan.py +196 -0
  7. scipplan/translation/constants_infection_1.txt +17 -0
  8. scipplan/translation/constants_navigation_1.txt +2 -0
  9. scipplan/translation/constants_navigation_2.txt +2 -0
  10. scipplan/translation/constants_navigation_3.txt +1 -0
  11. scipplan/translation/constants_pandemic_1.txt +17 -0
  12. scipplan/translation/goals_infection_1.txt +3 -0
  13. scipplan/translation/goals_navigation_1.txt +2 -0
  14. scipplan/translation/goals_navigation_2.txt +2 -0
  15. scipplan/translation/goals_navigation_3.txt +2 -0
  16. scipplan/translation/goals_pandemic_1.txt +3 -0
  17. scipplan/translation/initials_infection_1.txt +5 -0
  18. scipplan/translation/initials_navigation_1.txt +4 -0
  19. scipplan/translation/initials_navigation_2.txt +4 -0
  20. scipplan/translation/initials_navigation_3.txt +4 -0
  21. scipplan/translation/initials_pandemic_1.txt +5 -0
  22. scipplan/translation/instantaneous_constraints_infection_1.txt +12 -0
  23. scipplan/translation/instantaneous_constraints_navigation_1.txt +9 -0
  24. scipplan/translation/instantaneous_constraints_navigation_2.txt +10 -0
  25. scipplan/translation/instantaneous_constraints_navigation_3.txt +11 -0
  26. scipplan/translation/instantaneous_constraints_pandemic_1.txt +12 -0
  27. scipplan/translation/pvariables_infection_1.txt +12 -0
  28. scipplan/translation/pvariables_navigation_1.txt +8 -0
  29. scipplan/translation/pvariables_navigation_2.txt +8 -0
  30. scipplan/translation/pvariables_navigation_3.txt +8 -0
  31. scipplan/translation/pvariables_pandemic_1.txt +12 -0
  32. scipplan/translation/reward_infection_1.txt +1 -0
  33. scipplan/translation/reward_navigation_1.txt +1 -0
  34. scipplan/translation/reward_navigation_2.txt +1 -0
  35. scipplan/translation/reward_navigation_3.txt +1 -0
  36. scipplan/translation/reward_pandemic_1.txt +1 -0
  37. scipplan/translation/temporal_constraints_infection_1.txt +1 -0
  38. scipplan/translation/temporal_constraints_navigation_1.txt +6 -0
  39. scipplan/translation/temporal_constraints_navigation_2.txt +6 -0
  40. scipplan/translation/temporal_constraints_navigation_3.txt +7 -0
  41. scipplan/translation/temporal_constraints_pandemic_1.txt +1 -0
  42. scipplan/translation/transitions_infection_1.txt +7 -0
  43. scipplan/translation/transitions_navigation_1.txt +4 -0
  44. scipplan/translation/transitions_navigation_2.txt +4 -0
  45. scipplan/translation/transitions_navigation_3.txt +4 -0
  46. scipplan/translation/transitions_pandemic_1.txt +7 -0
  47. scipplan/variables.py +91 -0
  48. scipplan/zero_crossing.py +28 -0
  49. scipplan-0.1.0a0.dist-info/LICENSE +19 -0
  50. scipplan-0.1.0a0.dist-info/METADATA +215 -0
  51. scipplan-0.1.0a0.dist-info/RECORD +54 -0
  52. scipplan-0.1.0a0.dist-info/WHEEL +6 -0
  53. scipplan-0.1.0a0.dist-info/entry_points.txt +2 -0
  54. scipplan-0.1.0a0.dist-info/top_level.txt +1 -0
@@ -0,0 +1 @@
1
+ -1.0*(Dt + Mode * Epsilon)
@@ -0,0 +1 @@
1
+ -1.0*(Dt + Epsilon * Mode)
@@ -0,0 +1 @@
1
+ -1.0*(Dt+Epsilon*Mode)
@@ -0,0 +1 @@
1
+ -1.0 * Lockdown * Dt
@@ -0,0 +1 @@
1
+ Infected * exp((b / (b - c)) * log(1 + (Infected / Susceptible))) * exp(-1.0 * (b / (b - c)) * log(1 + (Infected / Susceptible) * exp((b - c) * Dt))) * exp((b - c) * Dt) <= D
@@ -0,0 +1,6 @@
1
+ Location_x + Speed_x*(Dt + Epsilon*Mode) + 0.5*Accelerate_x*(Dt + Epsilon*Mode)*(Dt + Epsilon*Mode) <= 10.0
2
+ Location_y + Speed_y*(Dt + Epsilon*Mode) + 0.5*Accelerate_y*(Dt + Epsilon*Mode)*(Dt + Epsilon*Mode) <= 10.0
3
+ Location_x + Speed_x*(Dt + Epsilon*Mode) + 0.5*Accelerate_x*(Dt + Epsilon*Mode)*(Dt + Epsilon*Mode) >= 0.0
4
+ Location_y + Speed_y*(Dt + Epsilon*Mode) + 0.5*Accelerate_y*(Dt + Epsilon*Mode)*(Dt + Epsilon*Mode) >= 0.0
5
+
6
+ (Location_x + Speed_x*(Dt + Epsilon*Mode) + 0.5*Accelerate_x*(Dt + Epsilon*Mode)*(Dt + Epsilon*Mode) <= 4.0) or (Location_x + Speed_x*(Dt + Epsilon*Mode) + 0.5*Accelerate_x*(Dt + Epsilon*Mode)*(Dt + Epsilon*Mode) >= 6.0) or (Location_y + Speed_y*(Dt + Epsilon*Mode) + 0.5*Accelerate_y*(Dt + Epsilon*Mode)*(Dt + Epsilon*Mode) <= 4.0) or (Location_y + Speed_y*(Dt + Epsilon*Mode) + 0.5*Accelerate_y*(Dt + Epsilon*Mode)*(Dt + Epsilon*Mode) >= 6.0)
@@ -0,0 +1,6 @@
1
+ Location_x + Speed_x*(Dt + Epsilon*Mode) + 0.5*Accelerate_x*(Dt + Epsilon*Mode)*(Dt + Epsilon*Mode) <= 10.0
2
+ Location_y + Speed_y*(Dt + Epsilon*Mode) + 0.5*Accelerate_y*(Dt + Epsilon*Mode)*(Dt + Epsilon*Mode) <= 10.0
3
+ Location_x + Speed_x*(Dt + Epsilon*Mode) + 0.5*Accelerate_x*(Dt + Epsilon*Mode)*(Dt + Epsilon*Mode) >= 0.0
4
+ Location_y + Speed_y*(Dt + Epsilon*Mode) + 0.5*Accelerate_y*(Dt + Epsilon*Mode)*(Dt + Epsilon*Mode) >= 0.0
5
+ (Location_x + Speed_x*(Dt + Epsilon*Mode) + 0.5*Accelerate_x*(Dt + Epsilon*Mode)*(Dt + Epsilon*Mode) <= 2.0) or (Location_x + Speed_x*(Dt + Epsilon*Mode) + 0.5*Accelerate_x*(Dt + Epsilon*Mode)*(Dt + Epsilon*Mode) >= 4.0) or (Location_y + Speed_y*(Dt + Epsilon*Mode) + 0.5*Accelerate_y*(Dt + Epsilon*Mode)*(Dt + Epsilon*Mode) <= 1.0) or (Location_y + Speed_y*(Dt + Epsilon*Mode) + 0.5*Accelerate_y*(Dt + Epsilon*Mode)*(Dt + Epsilon*Mode) >= 5.0)
6
+ (Location_x + Speed_x*(Dt + Epsilon*Mode) + 0.5*Accelerate_x*(Dt + Epsilon*Mode)*(Dt + Epsilon*Mode) <= 5.0) or (Location_x + Speed_x*(Dt + Epsilon*Mode) + 0.5*Accelerate_x*(Dt + Epsilon*Mode)*(Dt + Epsilon*Mode) >= 7.0) or (Location_y + Speed_y*(Dt + Epsilon*Mode) + 0.5*Accelerate_y*(Dt + Epsilon*Mode)*(Dt + Epsilon*Mode) <= 5.0) or (Location_y + Speed_y*(Dt + Epsilon*Mode) + 0.5*Accelerate_y*(Dt + Epsilon*Mode)*(Dt + Epsilon*Mode) >= 9.0)
@@ -0,0 +1,7 @@
1
+ Location_x + Speed_x*(Dt+Epsilon*Mode) + 0.5*Accelerate_x*(Dt+Epsilon*Mode)*(Dt+Epsilon*Mode) <= 10.0
2
+ Location_y + Speed_y*(Dt+Epsilon*Mode) + 0.5*Accelerate_y*(Dt+Epsilon*Mode)*(Dt+Epsilon*Mode) <= 10.0
3
+ Location_x + Speed_x*(Dt+Epsilon*Mode) + 0.5*Accelerate_x*(Dt+Epsilon*Mode)*(Dt+Epsilon*Mode) >= 0.0
4
+ Location_y + Speed_y*(Dt+Epsilon*Mode) + 0.5*Accelerate_y*(Dt+Epsilon*Mode)*(Dt+Epsilon*Mode) >= 0.0
5
+ (Location_x + Speed_x*(Dt+Epsilon*Mode) + 0.5*Accelerate_x*(Dt+Epsilon*Mode)*(Dt+Epsilon*Mode) <= 2.0) or (Location_x + Speed_x*(Dt+Epsilon*Mode) + 0.5*Accelerate_x*(Dt+Epsilon*Mode)*(Dt+Epsilon*Mode) >= 4.0) or (Location_y + Speed_y*(Dt+Epsilon*Mode) + 0.5*Accelerate_y*(Dt+Epsilon*Mode)*(Dt+Epsilon*Mode) <= 1.0) or (Location_y + Speed_y*(Dt+Epsilon*Mode) + 0.5*Accelerate_y*(Dt+Epsilon*Mode)*(Dt+Epsilon*Mode) >= 9.0)
6
+ (Location_x + Speed_x*(Dt+Epsilon*Mode) + 0.5*Accelerate_x*(Dt+Epsilon*Mode)*(Dt+Epsilon*Mode) <= 4.0) or (Location_x + Speed_x*(Dt+Epsilon*Mode) + 0.5*Accelerate_x*(Dt+Epsilon*Mode)*(Dt+Epsilon*Mode) >= 7.0) or (Location_y + Speed_y*(Dt+Epsilon*Mode) + 0.5*Accelerate_y*(Dt+Epsilon*Mode)*(Dt+Epsilon*Mode) <= 7.0) or (Location_y + Speed_y*(Dt+Epsilon*Mode) + 0.5*Accelerate_y*(Dt+Epsilon*Mode)*(Dt+Epsilon*Mode) >= 9.0)
7
+ (Location_x + Speed_x*(Dt+Epsilon*Mode) + 0.5*Accelerate_x*(Dt+Epsilon*Mode)*(Dt+Epsilon*Mode) <= 4.0) or (Location_x + Speed_x*(Dt+Epsilon*Mode) + 0.5*Accelerate_x*(Dt+Epsilon*Mode)*(Dt+Epsilon*Mode) >= 9.0) or (Location_y + Speed_y*(Dt+Epsilon*Mode) + 0.5*Accelerate_y*(Dt+Epsilon*Mode)*(Dt+Epsilon*Mode) <= 2.0) or (Location_y + Speed_y*(Dt+Epsilon*Mode) + 0.5*Accelerate_y*(Dt+Epsilon*Mode)*(Dt+Epsilon*Mode) >= 6.0)
@@ -0,0 +1 @@
1
+ Infected * exp((b / (b - c)) * log(1 + (Infected / Susceptible))) * exp(-1.0 * (b / (b - c)) * log(1 + (Infected / Susceptible) * exp((b - c) * Dt))) * exp((b - c) * Dt) <= D
@@ -0,0 +1,7 @@
1
+ Susceptible_dash - Susceptible * exp((b / (b - c)) * log(1 + (Infected / Susceptible))) * exp(-1.0 * (b / (b - c)) * log(1 + (Infected / Susceptible) * exp((b - c) * Dt))) == 0.0
2
+
3
+ Infected_dash - Infected * exp((b / (b - c)) * log(1 + (Infected / Susceptible))) * exp(-1.0 * (b / (b - c)) * log(1 + (Infected / Susceptible) * exp((b - c) * Dt))) * exp((b - c) * Dt) == 0.0
4
+
5
+ Removed_dash - N + exp((b / (b - c)) * log(Susceptible + Infected)) * exp(-1.0 * (c / (b - c)) * log(Susceptible + Infected * exp((b - c) * Dt))) == 0.0
6
+
7
+ TotalTime_dash - TotalTime - Dt == 0
@@ -0,0 +1,4 @@
1
+ Location_x_dash - 1.0*Location_x - 1.0*Speed_x*(Dt + Epsilon*Mode) - 0.5*Accelerate_x*(Dt + Epsilon*Mode)*(Dt + Epsilon*Mode) == 0.0
2
+ Location_y_dash - 1.0*Location_y - 1.0*Speed_y*(Dt + Epsilon*Mode) - 0.5*Accelerate_y*(Dt + Epsilon*Mode)*(Dt + Epsilon*Mode) == 0.0
3
+ Speed_x_dash - 1.0*Speed_x - 1.0*Accelerate_x*(Dt + Epsilon*Mode) == 0.0
4
+ Speed_y_dash - 1.0*Speed_y - 1.0*Accelerate_y*(Dt + Epsilon*Mode) == 0.0
@@ -0,0 +1,4 @@
1
+ Location_x_dash - 1.0*Location_x - 1.0*Speed_x*(Dt + Epsilon*Mode) - 0.5*Accelerate_x*(Dt + Epsilon*Mode)*(Dt + Epsilon*Mode) == 0.0
2
+ Location_y_dash - 1.0*Location_y - 1.0*Speed_y*(Dt + Epsilon*Mode) - 0.5*Accelerate_y*(Dt + Epsilon*Mode)*(Dt + Epsilon*Mode) == 0.0
3
+ Speed_x_dash - 1.0*Speed_x - 1.0*Accelerate_x*(Dt + Epsilon*Mode) == 0.0
4
+ Speed_y_dash - 1.0*Speed_y - 1.0*Accelerate_y*(Dt + Epsilon*Mode) == 0.0
@@ -0,0 +1,4 @@
1
+ Location_x_dash - 1.0*Location_x - 1.0*Speed_x*(Dt+Epsilon*Mode) - 0.5*Accelerate_x*(Dt+Epsilon*Mode)*(Dt+Epsilon*Mode) == 0.0
2
+ Location_y_dash - 1.0*Location_y - 1.0*Speed_y*(Dt+Epsilon*Mode) - 0.5*Accelerate_y*(Dt+Epsilon*Mode)*(Dt+Epsilon*Mode) == 0.0
3
+ Speed_x_dash - 1.0*Speed_x - 1.0*Accelerate_x*(Dt+Epsilon*Mode) == 0.0
4
+ Speed_y_dash - 1.0*Speed_y - 1.0*Accelerate_y*(Dt+Epsilon*Mode) == 0.0
@@ -0,0 +1,7 @@
1
+ Susceptible_dash - Susceptible * exp((b / (b - c)) * log(1 + (Infected / Susceptible))) * exp(-1.0 * (b / (b - c)) * log(1 + (Infected / Susceptible) * exp((b - c) * Dt))) == 0.0
2
+
3
+ Infected_dash - Infected * exp((b / (b - c)) * log(1 + (Infected / Susceptible))) * exp(-1.0 * (b / (b - c)) * log(1 + (Infected / Susceptible) * exp((b - c) * Dt))) * exp((b - c) * Dt) == 0.0
4
+
5
+ Removed_dash - N + exp((b / (b - c)) * log(Susceptible + Infected)) * exp(-1.0 * (c / (b - c)) * log(Susceptible + Infected * exp((b - c) * Dt))) == 0.0
6
+
7
+ TotalTime_dash - TotalTime - Dt == 0
scipplan/variables.py ADDED
@@ -0,0 +1,91 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+ from enum import Enum
5
+ from typing import Union
6
+
7
+ from pyscipopt.scip import Model, Variable as SCIPVariable
8
+
9
+ @dataclass
10
+ class Variable:
11
+ name: str
12
+ var_type: VarType
13
+ val_type: ValType
14
+ time: int
15
+ model: Model
16
+ model_var: Union[SCIPVariable | float]
17
+
18
+ @classmethod
19
+ def create_var(cls, model: Model, name: str, vtype: str, time: int, const_vals: dict[str, float]) -> Variable:
20
+
21
+ if "action" in vtype:
22
+ var_type = VarType.ACTION
23
+ elif "state" in vtype:
24
+ var_type = VarType.STATE
25
+ elif "auxiliary" in vtype:
26
+ var_type = VarType.AUX
27
+ elif "constant" in vtype:
28
+ var_type = VarType.CONSTANT
29
+ else: # var type isn't recognised
30
+ raise Exception("Unknown variable type: ")
31
+
32
+ if "continuous" in vtype:
33
+ val_type = ValType.CONTINUOUS
34
+ elif "integer" in vtype:
35
+ val_type = ValType.INTEGER
36
+ elif "boolean" in vtype:
37
+ val_type = ValType.BOOLEAN
38
+ elif var_type is VarType.CONSTANT:
39
+ # Special case for constants as the value type doesn't matter for the model as it is numeric
40
+ val_type = None
41
+ else: # val type isn't recognised
42
+ raise Exception("Unkown value type: ")
43
+
44
+ if var_type is VarType.CONSTANT:
45
+ model_var = const_vals[name]
46
+ else:
47
+ model_var = model.addVar(name=f"{name}_{time}", vtype=val_type.value, lb=None, ub=None)
48
+
49
+ var = Variable(
50
+ name=name,
51
+ var_type=var_type,
52
+ val_type=val_type,
53
+ time=time,
54
+ model=model,
55
+ model_var=model_var
56
+ )
57
+
58
+ return var
59
+
60
+ def to_dict(self):
61
+ if self.var_type is VarType.CONSTANT:
62
+ var_val = self.model_var
63
+ val_type = None
64
+ else:
65
+ val_type = self.val_type.name
66
+ try:
67
+ var_val = self.model.getVal(self.model_var)
68
+ except Warning:
69
+ var_val = None
70
+
71
+
72
+ return {
73
+ "name": self.name,
74
+ "variable_type": self.var_type.name,
75
+ "value_type": val_type,
76
+ "horizon": self.time,
77
+ "variable_value": var_val
78
+ }
79
+
80
+
81
+
82
+ class VarType(Enum):
83
+ ACTION = "action"
84
+ STATE = "state"
85
+ AUX = "auxiliary"
86
+ CONSTANT = "constant"
87
+
88
+ class ValType(Enum):
89
+ CONTINUOUS = "C"
90
+ INTEGER = "I"
91
+ BOOLEAN = "B"
@@ -0,0 +1,28 @@
1
+ from dataclasses import field, dataclass
2
+ from textwrap import dedent
3
+
4
+ @dataclass
5
+ class ZeroCrossing:
6
+ is_violated: bool = field(repr=False)
7
+ iteration: int = None
8
+ horizon: int = None
9
+ start: float = None
10
+ end: float = None
11
+ dt_interval: float = None
12
+ coef: float = field(init=False, default=None)
13
+ new_dt_val: float = field(init=False, default=None)
14
+
15
+ def __post_init__(self):
16
+ if self.is_violated is True:
17
+ if self.start is None or self.end is None or self.dt_interval is None:
18
+ raise ValueError(
19
+ dedent(f"""
20
+ Incorrect input values, start, end and dt_interval have to be specified when zero crossing exists
21
+
22
+ {self.start = }
23
+ {self.end = }
24
+ {self.dt_interval = }
25
+ """))
26
+ avg_interval = (self.start + self.end) / 2.0
27
+ self.coef = avg_interval / self.dt_interval
28
+ self.new_dt_val = self.coef * self.dt_interval
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2024 Ari Gestetner
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
@@ -0,0 +1,215 @@
1
+ Metadata-Version: 2.1
2
+ Name: scipplan
3
+ Version: 0.1.0a0
4
+ Summary: Metric Hybrid Factored Planning in Nonlinear Domains with Constraint Generation in Python.
5
+ Author: Ari Gestetner, Buser Say
6
+ Author-email: ages0001@student.monash.edu, buser.say@monash.edu
7
+ License: MIT License
8
+ Keywords: scip,automated planner
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Environment :: Console
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Natural Language :: English
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+
20
+ # SCIPPlan
21
+
22
+ SCIPPlan [1,2,3] is a SCIP-based [4] hybrid planner for domains with i) mixed (i.e., real and/or discrete valued) state and action spaces, ii) nonlinear state transitions that are functions of time, and iii) general reward functions. SCIPPlan iteratively i) finds violated constraints (i.e., zero-crossings) by simulating the state transitions, and ii) adds the violated (symbolic) constraints back to its underlying optimisation model, until a valid plan is found.
23
+
24
+ ## Example Domain: Navigation
25
+
26
+ <img src=./visualisation/scipplan_navigation_1.gif width="32%" height="32%"> <img src=./visualisation/scipplan_navigation_2.gif width="32%" height="32%"> <img src=./visualisation/scipplan_navigation_3.gif width="32%" height="32%">
27
+
28
+
29
+ Figure 1: Visualisation of different plans generated by SCIPPlan [1,2,3] for example navigation domains where the red square represents the agent, the blue shapes represent the obstacles, the gold star represents the goal location and the delta represents time. The agent can control its acceleration and the duration of its control input to modify its speed and location in order to navigate in a two-dimensional maze. The purpose of the domain is to find a path for the agent with minimum makespan such that the agent reaches its the goal without colliding with the obstacles.
30
+
31
+ Note that SCIPPlan does not linearise or discretise the domain to find a valid plan.
32
+
33
+ ## Dependencies
34
+
35
+ i) Solver: SCIP (the current implementation uses the python interface to the SCIP solver, i.e., PySCIPOpt [5]). This version of SCIPPlan has only been tested on PySCIOpt>=4.0.0 using earlier an version of pyscipopt may result in unintended behaviour.
36
+
37
+ ## Installing and Running SCIPPlan
38
+ In order to Install SCIPPlan you need to ensure you have a working version of the SCIP optimisation suite on your system which can be installed from [the SCIP website](https://www.scipopt.org). For more information about SCIP and PySCIPOpt refer to this [installation guide](https://github.com/scipopt/PySCIPOpt/blob/master/INSTALL.md).
39
+
40
+ After installing SCIP you will be able to install SCIPPlan using
41
+ ```bash
42
+ pip install scipplan
43
+ ```
44
+ Now you will be able to run some of the example domains which include
45
+ - Navigation (3 instances)
46
+
47
+ To run one of these examples all you need to do is run
48
+ ```bash
49
+ scipplan -D navigation -I 1
50
+ ```
51
+ which will run the 1st instance of the navigation domain. For more information regarding the available tags and what they mean run `scipplan --help`.
52
+
53
+ Alternatively you can import scipplan classes to run it using python.
54
+ ```py
55
+ from scipplan.scipplan import SCIPPlan
56
+ from scipplan.config import Config
57
+ from scipplan.helpers import write_to_csv
58
+ ```
59
+ this will import the only 2 classes and function needed to run SCIPPlan. Then to set the configuration either create an instance of the Config class by setting the params or by retrieving the cli input
60
+ ```py
61
+ # Set params
62
+ config = Config(domain="navigation", instance=1)
63
+ # Retrieve cli args
64
+ config = Config.get_config()
65
+ ```
66
+ after which you are able to solve problem by either using the solve or optimize methods
67
+ ```py
68
+ # The optimize method just optimises the problem for the given horizon
69
+ plan = SCIPPlan(config)
70
+ plan.optimize()
71
+ # Class method which takes input the config, solves the problem
72
+ # with auto incrementing the horizon until a solution is found then
73
+ # returns the plan as well as the time taken to solve the problem
74
+ plan, solve_time = SCIPPlan.solve(config)
75
+ ```
76
+ In order to save the generated constraints for the horizon solved as well as the results, use the following code
77
+ ```py
78
+ write_to_csv("new_constraints", plan.new_constraints, config)
79
+ write_to_csv("results", plan.results_table, config)
80
+ ```
81
+
82
+
83
+
84
+ ## Custom Domains
85
+ If you would like to create your own domain you will need to create a directory named "translation" in the directory which scipplan is run from with txt files of the format "{translation type}\_{domain name}\_{instance number}.txt" (e.g. "pvariables_navigation_1.txt"). Note that the files in the translation directory will override any example files if they share domain name and instance number (e.g. navigation 1 would override the example).
86
+
87
+ For each domain instance the following translation files are required
88
+ - constants
89
+ - pvariables
90
+ - initials
91
+ - goals
92
+ - instantaneous_constraints
93
+ - temporal_constraints
94
+ - transitions
95
+ - reward
96
+
97
+ As a part of SCIPPlan, all the constraint files allow for the use of "and" and "or" expressions, polynomials and `exp`, `log`, `sqrt`, `sin` and `cos` functions (Note: `sin` and `cos` are only available in PySCIPOpt>=4.3.0 so if your version is below that you will not be able to use the trig functions unless you update).
98
+
99
+ ### Constants
100
+ The constants file allows for constant values to be defined as a variable to be used in other files in the model. To use add constants as follows
101
+ ```txt
102
+ HalfVal = 0.5
103
+ Epsilon = config_epsilon
104
+ bigM = config_bigM
105
+ ```
106
+
107
+ Some config values can be accessed in the constants file to be used in other files and are available as
108
+ - `config_epsilon`
109
+ - `config_gap`
110
+ - `config_bigM`
111
+ Note that these variables are only accessible in the constants file and you will need to define a new constants variable to store the value
112
+
113
+ ### Pvariables
114
+ When creating the pvariables file, the variables should be listed in the following format
115
+ ```txt
116
+ action_continuous: Accelerate_x
117
+ action_continuous: Accelerate_y
118
+ action_continuous: Dt
119
+ action_boolean: Mode
120
+ state_continuous: Location_x
121
+ state_continuous: Location_y
122
+ state_continuous: Speed_x
123
+ state_continuous: Speed_y
124
+ ```
125
+ where the variable and value type of the variable is set in the format "{variable type}_{value type}" and the variable itself has to be in a Python compatible format (e.g. variables can't use - sign like `some-var` but can use _ like `some_var` as well as the dash sign ' cannot be used). The use of next state variables which is often written using the dash symbol will be explained further in the Transitions section.
126
+ Additionally a variable for Dt has to be defined and has to be the same as the dt_var in the config object so if you would like to use a different variable name for Dt (e.g. dt) please also ensure you add it to the config via the `--dt-var` tag or the `dt_var` parameter.
127
+ The available variable types are
128
+ - state
129
+ - action
130
+ - auxiliary
131
+
132
+ The available value types are
133
+ - continuos
134
+ - integer
135
+ - boolean
136
+
137
+ Please note that constants don't need to have their variable names defined in pvariables as they are defined in constants.
138
+
139
+ ### Initials
140
+ The initials file defines the initial state values for time t=0, for example
141
+ ```txt
142
+ Location_x == 0.0
143
+ Location_y == 0.0
144
+ Speed_x == 0.0
145
+ Speed_y == 0.0
146
+ ```
147
+ notice te use of teh constant value defined earlier in the constants file.
148
+ ### Goals
149
+ The goals file should encode the final state values such that t=H+1, for example
150
+ ```txt
151
+ Location_x == 8.0
152
+ Location_y == 8.0
153
+ ```
154
+ ### Instantaneous Constraints
155
+ This is where the instantaneous constraints go.
156
+ An example is as follows
157
+ ```txt
158
+ Location_x <= 10.0
159
+ Location_y <= 10.0
160
+ Location_x >= 0.0
161
+ Location_y >= 0.0
162
+ Accelerate_x <= 0.5
163
+ Accelerate_y <= 0.5
164
+ Accelerate_x >= -0.5
165
+ Accelerate_y >= -0.5
166
+ (Location_x <= 4.0) or (Location_x >= 6.0) or (Location_y <= 4.0) or (Location_y >= 6.0)
167
+ ```
168
+ ### Temporal Constraints
169
+ The temporal constraints are the constraints which SCIPPlan will ensure that the solution never violates by iterating through every epsilon value of Dt and checking for zero crossings. An example of a temporal constraint is as follows
170
+ ```txt
171
+ Location_x + Speed_x*(Dt + Epsilon*Mode) + 0.5*Accelerate_x*(Dt + Epsilon*Mode)*(Dt + Epsilon*Mode) <= 10.0
172
+ Location_y + Speed_y*(Dt + Epsilon*Mode) + 0.5*Accelerate_y*(Dt + Epsilon*Mode)*(Dt + Epsilon*Mode) <= 10.0
173
+ Location_x + Speed_x*(Dt + Epsilon*Mode) + 0.5*Accelerate_x*(Dt + Epsilon*Mode)*(Dt + Epsilon*Mode) >= 0.0
174
+ Location_y + Speed_y*(Dt + Epsilon*Mode) + 0.5*Accelerate_y*(Dt + Epsilon*Mode)*(Dt + Epsilon*Mode) >= 0.0
175
+
176
+ ((Location_x + Speed_x*(Dt + Epsilon*Mode) + 0.5*Accelerate_x*(Dt + Epsilon*Mode)*(Dt + Epsilon*Mode) <= 4.0) or
177
+ (Location_x + Speed_x*(Dt + Epsilon*Mode) + 0.5*Accelerate_x*(Dt + Epsilon*Mode)*(Dt + Epsilon*Mode) >= 6.0) or
178
+ (Location_y + Speed_y*(Dt + Epsilon*Mode) + 0.5*Accelerate_y*(Dt + Epsilon*Mode)*(Dt + Epsilon*Mode) <= 4.0) or
179
+ (Location_y + Speed_y*(Dt + Epsilon*Mode) + 0.5*Accelerate_y*(Dt + Epsilon*Mode)*(Dt + Epsilon*Mode) >= 6.0))
180
+ ```
181
+
182
+ The use of mode switches are used in these constraints (`Dt + Epsilon*Mode`). Please note that the or expression is enclosed in round brackets which allows the constraints to be parsed as a singular expression
183
+ ### Transitions
184
+ Transitions are to be added here with the following syntax.
185
+ For example $S_{t+1} = \frac 12 A_t\cdot t^2 + V_t\cdot t + S_t$.
186
+ Alternatively this can be written as $S' = \frac 12 A\cdot t^2 + V\cdot t + S$.
187
+ Since Python doesn't allow variables to use the ' symbol it should be replaced with `_dash`, for example
188
+ ```txt
189
+ Location_x_dash - 1.0*Location_x - 1.0*Speed_x*(Dt + Epsilon*Mode) - 0.5*Accelerate_x*(Dt + Epsilon*Mode)*(Dt + Epsilon*Mode) == 0.0
190
+ Location_y_dash - 1.0*Location_y - 1.0*Speed_y*(Dt + Epsilon*Mode) - 0.5*Accelerate_y*(Dt + Epsilon*Mode)*(Dt + Epsilon*Mode) == 0.0
191
+ Speed_x_dash - 1.0*Speed_x - 1.0*Accelerate_x*(Dt + Epsilon*Mode) == 0.0
192
+ Speed_y_dash - 1.0*Speed_y - 1.0*Accelerate_y*(Dt + Epsilon*Mode) == 0.0
193
+ ```
194
+
195
+ ### Reward
196
+ As for the reward function, SCIPPlan maximises the reward thus if using a cost function it should be negated as per the example
197
+ ```txt
198
+ -1.0*(Dt + Mode * Epsilon)
199
+ ```
200
+ Only one reward function is able to be optimised for in SCIPPlan
201
+
202
+ ## Citation
203
+
204
+ If you are using SCIPPlan, please cite the papers [1,2,3] and the underlying SCIP solver [4].
205
+
206
+ ## References
207
+ [1] Buser Say and Scott Sanner. [Metric Nonlinear Hybrid Planning with Constraint Generation](http://icaps18.icaps-conference.org/fileadmin/alg/conferences/icaps18/workshops/workshop06/docs/proceedings.pdf#page=23). In PlanSOpt, pages 19-25, 2018.
208
+
209
+ [2] Buser Say and Scott Sanner. [Metric Hybrid Factored Planning in Nonlinear Domains with Constraint Generation](https://link.springer.com/chapter/10.1007/978-3-030-19212-9_33). In CPAIOR, pages 502-518, 2019.
210
+
211
+ [3] Buser Say. [Robust Metric Hybrid Planning in Stochastic Nonlinear Domains Using Mathematical Optimization](https://ojs.aaai.org/index.php/ICAPS/article/view/27216). In ICAPS, pages 375-383, 2023.
212
+
213
+ [4] [SCIP](https://www.scipopt.org/)
214
+
215
+ [5] [PySCIPOpt](https://github.com/SCIP-Interfaces/PySCIPOpt)
@@ -0,0 +1,54 @@
1
+ scipplan/__init__.py,sha256=DFKsXFuWCEPlRh1XozFuUiyTqLf47yVYHnKpFjKtbkI,196
2
+ scipplan/config.py,sha256=VmsdogXHy535KheufJtREI8ZQ7lJVxYxzzPXzLoU-38,5136
3
+ scipplan/helpers.py,sha256=YwEr0NeDvb29_Ot686km3ZMJ-vHu-L8zjuexmlKDjpY,974
4
+ scipplan/parse_model.py,sha256=THP1TX6kllK4fwvxVGuzGIS4w2PVCg83GP1QhLiA8U0,10516
5
+ scipplan/plan_model.py,sha256=daHnVHn2e89OtXXMl63QEoeKGOmy_LwT2oCRTjUUlKQ,11145
6
+ scipplan/scipplan.py,sha256=aoHXP4YhYn9IAY4N2ZKQGgzKTG1tDEC_TpVctnO307k,7741
7
+ scipplan/variables.py,sha256=3sxY3zQuxsa5z2fTFjv4zOSb9GarzojZ4W4kIx9FX68,2561
8
+ scipplan/zero_crossing.py,sha256=kGyJsWZLLXqLW1p3LPDlPC34rTkFF8daDzqgbEcaXus,1043
9
+ scipplan/translation/constants_infection_1.txt,sha256=7MFkFGycNWOrdDJ7gZyEPmVtAzphbJXnXMFv1ogT3bg,179
10
+ scipplan/translation/constants_navigation_1.txt,sha256=X0jvJe5MiwvayKBVXo9TQlGZGfUlpnFpMiReL68rsXc,43
11
+ scipplan/translation/constants_navigation_2.txt,sha256=eMN8PnTBS5qc_8u6W7Q-wSlXvX_wFjFaFCT38wviiQE,44
12
+ scipplan/translation/constants_navigation_3.txt,sha256=ItHwvPfASUvSbdKlek4GFZweDGmxT1wRr3SH7W4-CBc,24
13
+ scipplan/translation/constants_pandemic_1.txt,sha256=7MFkFGycNWOrdDJ7gZyEPmVtAzphbJXnXMFv1ogT3bg,179
14
+ scipplan/translation/goals_infection_1.txt,sha256=IuVcZ7jkt1f12UR0y8FsyqUNZ8ypYLLqlTeFte5u6zQ,49
15
+ scipplan/translation/goals_navigation_1.txt,sha256=uxlsrr_M5maa8FGVZXrsnzu7CG-R1ubKVu8Wj5eAqks,35
16
+ scipplan/translation/goals_navigation_2.txt,sha256=uxlsrr_M5maa8FGVZXrsnzu7CG-R1ubKVu8Wj5eAqks,35
17
+ scipplan/translation/goals_navigation_3.txt,sha256=uxlsrr_M5maa8FGVZXrsnzu7CG-R1ubKVu8Wj5eAqks,35
18
+ scipplan/translation/goals_pandemic_1.txt,sha256=IuVcZ7jkt1f12UR0y8FsyqUNZ8ypYLLqlTeFte5u6zQ,49
19
+ scipplan/translation/initials_infection_1.txt,sha256=PM5-6kvHk-VMV_sSWpvC2tbq5Uvavm4DRelrRKOGsCQ,95
20
+ scipplan/translation/initials_navigation_1.txt,sha256=6uKI2B_vG-AACgFrBmmPBqC_NEQ2znHTcV44aI-rbXY,66
21
+ scipplan/translation/initials_navigation_2.txt,sha256=s7ukUEHwcmMsey1bHCRJh515PLKYXODz8Sb5jQBtGeM,65
22
+ scipplan/translation/initials_navigation_3.txt,sha256=s7ukUEHwcmMsey1bHCRJh515PLKYXODz8Sb5jQBtGeM,65
23
+ scipplan/translation/initials_pandemic_1.txt,sha256=PM5-6kvHk-VMV_sSWpvC2tbq5Uvavm4DRelrRKOGsCQ,95
24
+ scipplan/translation/instantaneous_constraints_infection_1.txt,sha256=gr9bxKFi_A3ZMCxB1nFemLrnJZpNvWzc9em4lk8AZuc,167
25
+ scipplan/translation/instantaneous_constraints_navigation_1.txt,sha256=WbITeszv_n93_BhE2eiNqFPAZVO4f2s44KcKUsNURyA,244
26
+ scipplan/translation/instantaneous_constraints_navigation_2.txt,sha256=e5YdZn3OKLJh0kEiCNqpOgxgAAQxIHMB3J5OTYvPlgw,333
27
+ scipplan/translation/instantaneous_constraints_navigation_3.txt,sha256=HnzfFntGIQ0WIMnEfcYPg1cy7u9dJn3xuYqdXZVFFvE,422
28
+ scipplan/translation/instantaneous_constraints_pandemic_1.txt,sha256=gr9bxKFi_A3ZMCxB1nFemLrnJZpNvWzc9em4lk8AZuc,167
29
+ scipplan/translation/pvariables_infection_1.txt,sha256=TfBDRG_FrKgxRYUFCA2ypQJZCIWLvDhUzLr_DwQFiKA,187
30
+ scipplan/translation/pvariables_navigation_1.txt,sha256=97t5uPWAWKmtbDPJZIor5nn5qPU6aMcGdpLAuKnlDbQ,217
31
+ scipplan/translation/pvariables_navigation_2.txt,sha256=lGUNN04bC-CJFTThNC3dwP9kU2xGftSshx-24I6zlZw,216
32
+ scipplan/translation/pvariables_navigation_3.txt,sha256=1-yvM5BSJ5TXBlHkMbcXWd5zoc2ezSBpIIuM_zwEXSo,216
33
+ scipplan/translation/pvariables_pandemic_1.txt,sha256=TfBDRG_FrKgxRYUFCA2ypQJZCIWLvDhUzLr_DwQFiKA,187
34
+ scipplan/translation/reward_infection_1.txt,sha256=3AZZGt7w5voiqwVlEkc2-NXXh6NxBqFPWraCZKwhpcM,20
35
+ scipplan/translation/reward_navigation_1.txt,sha256=dvR0CkxkWRbO3wP0fenXDSDMpueEUtSUqw990UnCcJY,26
36
+ scipplan/translation/reward_navigation_2.txt,sha256=ck6uUGNhM_DWiG1hHN6_xTps1muychzqTOpz1iLF9bk,26
37
+ scipplan/translation/reward_navigation_3.txt,sha256=O8unFCIySCz4GCBX_9mQcm-JMn5Ur6upp3HBbA4e_C8,22
38
+ scipplan/translation/reward_pandemic_1.txt,sha256=3AZZGt7w5voiqwVlEkc2-NXXh6NxBqFPWraCZKwhpcM,20
39
+ scipplan/translation/temporal_constraints_infection_1.txt,sha256=pReUU1lQsTwrREYJwlEeslSp56boHCKaIE1kIrXbPV8,175
40
+ scipplan/translation/temporal_constraints_navigation_1.txt,sha256=h06iRA5TDr6R5XdjhEyYnZ3f-FQwUkbKGNw-t0k0jm8,875
41
+ scipplan/translation/temporal_constraints_navigation_2.txt,sha256=x73dbxxb_YzvdvtVNaJfG-S9ggf-yqTYdoU6NiDQBqk,1319
42
+ scipplan/translation/temporal_constraints_navigation_3.txt,sha256=Ki4nAX9-QtBbY9ZdHwHdqta8JQoLrAVvlZrLa1pWLnQ,1668
43
+ scipplan/translation/temporal_constraints_pandemic_1.txt,sha256=pReUU1lQsTwrREYJwlEeslSp56boHCKaIE1kIrXbPV8,175
44
+ scipplan/translation/transitions_infection_1.txt,sha256=iDxrZUngYgxgZmGTur4sSWLZssG9AGGuY_BaYHmoxn0,564
45
+ scipplan/translation/transitions_navigation_1.txt,sha256=kfnr3_A9mCfflLsL4aq7OeR_BHSNST6eYuAg4ZxaPoU,411
46
+ scipplan/translation/transitions_navigation_2.txt,sha256=kfnr3_A9mCfflLsL4aq7OeR_BHSNST6eYuAg4ZxaPoU,411
47
+ scipplan/translation/transitions_navigation_3.txt,sha256=aIPP3FOjXZ3G6sTqicEIZ0JKJxdxHCRRZIdc5bUPFBM,395
48
+ scipplan/translation/transitions_pandemic_1.txt,sha256=iDxrZUngYgxgZmGTur4sSWLZssG9AGGuY_BaYHmoxn0,564
49
+ scipplan-0.1.0a0.dist-info/LICENSE,sha256=tfR4peJA8KJtYEn1NzNV-LWQVRAserdq7OJgYghreR0,1057
50
+ scipplan-0.1.0a0.dist-info/METADATA,sha256=BePW-SSEWLg7-0QhOoaiBRWI336Wp6wJ8hB3iRg8flA,11236
51
+ scipplan-0.1.0a0.dist-info/WHEEL,sha256=-G_t0oGuE7UD0DrSpVZnq1hHMBV9DD2XkS5v7XpmTnk,110
52
+ scipplan-0.1.0a0.dist-info/entry_points.txt,sha256=3qiNbbp6qIwivyPmmikyp7ByCfmsa9rGFNJPcN9Is8I,52
53
+ scipplan-0.1.0a0.dist-info/top_level.txt,sha256=xO2FLRn7YQ-C25E8lagIEbik5T5FTr-Ta5bdiZezEPY,9
54
+ scipplan-0.1.0a0.dist-info/RECORD,,
@@ -0,0 +1,6 @@
1
+ Wheel-Version: 1.0
2
+ Generator: bdist_wheel (0.42.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py2-none-any
5
+ Tag: py3-none-any
6
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ scipplan = scipplan.scipplan:main
@@ -0,0 +1 @@
1
+ scipplan