Package: scipplan
SCIPPlanSCIPPlan [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.Example Domain: NavigationFigure 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.Note that SCIPPlan does not linearise or discretise the domain to find a valid plan.Dependenciesi) 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.Installing and Running SCIPPlanIn 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 fromthe SCIP website. For more information about SCIP and PySCIPOpt refer to thisinstallation guide.After installing SCIP you will be able to install SCIPPlan usingpipinstallscipplanNow you will be able to run some of the example domains which includeNavigation (3 instances)To run one of these examples all you need to do is runscipplan-Dnavigation-I1which will run the 1st instance of the navigation domain. For more information regarding the available tags and what they mean runscipplan --help.Alternatively you can import scipplan classes to run it using python.fromscipplan.scipplanimportSCIPPlanfromscipplan.configimportConfigfromscipplan.helpersimportwrite_to_csvthis 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# Set paramsconfig=Config(domain="navigation",instance=1)# Retrieve cli argsconfig=Config.get_config()after which you are able to solve problem by either using the solve or optimize methods# The optimize method just optimises the problem for the given horizonplan=SCIPPlan(config)plan.optimize()# Class method which takes input the config, solves the problem# with auto incrementing the horizon until a solution is found then# returns the plan as well as the time taken to solve the problemplan,solve_time=SCIPPlan.solve(config)In order to save the generated constraints for the horizon solved as well as the results, use the following codewrite_to_csv("new_constraints",plan.new_constraints,config)write_to_csv("results",plan.results_table,config)Custom DomainsIf 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).For each domain instance the following translation files are requiredconstantspvariablesinitialsgoalsinstantaneous_constraintstemporal_constraintstransitionsrewardAs a part of SCIPPlan, all the constraint files allow for the use of "and" and "or" expressions, polynomials andexp,log,sqrt,sinandcosfunctions (Note:sinandcosare 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).ConstantsThe 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 followsHalfVal = 0.5
Epsilon = config_epsilon
bigM = config_bigMSome config values can be accessed in the constants file to be used in other files and are available asconfig_epsilonconfig_gapconfig_bigMNote that these variables are only accessible in the constants file and you will need to define a new constants variable to store the valuePvariablesWhen creating the pvariables file, the variables should be listed in the following formataction_continuous: Accelerate_x
action_continuous: Accelerate_y
action_continuous: Dt
action_boolean: Mode
state_continuous: Location_x
state_continuous: Location_y
state_continuous: Speed_x
state_continuous: Speed_ywhere 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 likesome-varbut can use _ likesome_varas 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.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-vartag or thedt_varparameter.The available variable types arestateactionauxiliaryThe available value types arecontinuosintegerbooleanPlease note that constants don't need to have their variable names defined in pvariables as they are defined in constants.InitialsThe initials file defines the initial state values for time t=0, for exampleLocation_x == 0.0
Location_y == 0.0
Speed_x == 0.0
Speed_y == 0.0notice te use of teh constant value defined earlier in the constants file.GoalsThe goals file should encode the final state values such that t=H+1, for exampleLocation_x == 8.0
Location_y == 8.0Instantaneous ConstraintsThis is where the instantaneous constraints go.
An example is as followsLocation_x <= 10.0
Location_y <= 10.0
Location_x >= 0.0
Location_y >= 0.0
Accelerate_x <= 0.5
Accelerate_y <= 0.5
Accelerate_x >= -0.5
Accelerate_y >= -0.5
(Location_x <= 4.0) or (Location_x >= 6.0) or (Location_y <= 4.0) or (Location_y >= 6.0)Temporal ConstraintsThe 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 followsLocation_x + Speed_x*(Dt + Epsilon*Mode) + 0.5*Accelerate_x*(Dt + Epsilon*Mode)*(Dt + Epsilon*Mode) <= 10.0
Location_y + Speed_y*(Dt + Epsilon*Mode) + 0.5*Accelerate_y*(Dt + Epsilon*Mode)*(Dt + Epsilon*Mode) <= 10.0
Location_x + Speed_x*(Dt + Epsilon*Mode) + 0.5*Accelerate_x*(Dt + Epsilon*Mode)*(Dt + Epsilon*Mode) >= 0.0
Location_y + Speed_y*(Dt + Epsilon*Mode) + 0.5*Accelerate_y*(Dt + Epsilon*Mode)*(Dt + Epsilon*Mode) >= 0.0

((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))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 expressionTransitionsTransitions are to be added here with the following syntax.For example $S_{t+1} = \frac 12 A_t\cdot t^2 + V_t\cdot t + S_t$.Alternatively this can be written as $S' = \frac 12 A\cdot t^2 + V\cdot t + S$.
Since Python doesn't allow variables to use the ' symbol it should be replaced with_dash, for exampleLocation_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
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
Speed_x_dash - 1.0*Speed_x - 1.0*Accelerate_x*(Dt + Epsilon*Mode) == 0.0
Speed_y_dash - 1.0*Speed_y - 1.0*Accelerate_y*(Dt + Epsilon*Mode) == 0.0RewardAs for the reward function, SCIPPlan maximises the reward thus if using a cost function it should be negated as per the example-1.0*(Dt + Mode * Epsilon)Only one reward function is able to be optimised for in SCIPPlanCitationIf you are using SCIPPlan, please cite the papers [1,2,3] and the underlying SCIP solver [4].References[1] Buser Say and Scott Sanner.Metric Nonlinear Hybrid Planning with Constraint Generation. In PlanSOpt, pages 19-25, 2018.[2] Buser Say and Scott Sanner.Metric Hybrid Factored Planning in Nonlinear Domains with Constraint Generation. In CPAIOR, pages 502-518, 2019.[3] Buser Say.Robust Metric Hybrid Planning in Stochastic Nonlinear Domains Using Mathematical Optimization. In ICAPS, pages 375-383, 2023.[4]SCIP[5]PySCIPOpt