Skip to content

Commit

Permalink
Merge pull request #98 from plaans/release01
Browse files Browse the repository at this point in the history
Release 0.1
  • Loading branch information
arbimo authored Jul 6, 2023
2 parents a4b633d + 5b2484c commit ca09acb
Show file tree
Hide file tree
Showing 6 changed files with 161 additions and 11 deletions.
67 changes: 62 additions & 5 deletions planning/grpc/api/src/unified_planning.proto
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ message EffectExpression {
// If the effect is unconditional, the effect is set to the constant 'true' value.
// features: CONDITIONAL_EFFECT
Expression condition = 4;

// The variables that quantify this effect
repeated Expression forall = 5;
}

// Representation of an effect that allows qualifying the effect expression, e.g., to make it a conditional effect.
Expand Down Expand Up @@ -380,6 +383,50 @@ message Hierarchy {
TaskNetwork initial_task_network = 3;
}

// ============= Scheduling =======================

// Activity in a scheduling problem.
message Activity {
// Name of the activity that must uniquely identify it.
string name = 1;

// Typed and named parameters of the activity.
repeated Parameter parameters = 2;

// Duration of the activity
Duration duration = 3;

// Conjunction of conditions that must hold if the activity is present.
repeated Condition conditions = 4;

// Conjunction of effects that this activity produces.
repeated Effect effects = 5;

// Conjunction of static constraints that must hold if the activity is present.
repeated Expression constraints = 6;
}

// Extension of `Problem` for scheduling
message SchedulingExtension {
// All potential activities of the scheduling problem.
repeated Activity activities = 1;

// All variables in the base problem
repeated Parameter variables = 2;

// All constraints in the base problem.
repeated Expression constraints = 5;
}

message Schedule {
// Name of the activities that appear in the solution
repeated string activities = 1;

// Assignment of all variables and activity parameters and timepoints
// that appear in the solution.
map<string, Atom> variable_assignments = 2;
}



// ============== Problem =========================
Expand Down Expand Up @@ -481,7 +528,6 @@ message Metric {
repeated TimedGoalWithWeight timed_goals = 6;
}

// features: ACTION_BASED
message Problem {
string domain_name = 1;
string problem_name = 2;
Expand All @@ -490,6 +536,7 @@ message Problem {
repeated ObjectDeclaration objects = 5;

// List of actions in the domain.
// features: ACTION_BASED
repeated Action actions = 6;

// Initial state, including default values of state variables.
Expand All @@ -508,11 +555,14 @@ message Problem {
// The plan quality metrics
repeated Metric metrics = 11;


// If the problem is hierarchical, defines the tasks and methods as well as the initial task network.
// features: hierarchical
// features: HIERARCHICAL
Hierarchy hierarchy = 12;

// Scheduling-specific extension of the problem.
// features: SCHEDULING
SchedulingExtension scheduling_extension = 17;

// Trajectory constraints of the planning problem.
repeated Expression trajectory_constraints = 13;

Expand All @@ -532,6 +582,7 @@ enum Feature {
// PROBLEM_CLASS
ACTION_BASED = 0;
HIERARCHICAL = 26;
SCHEDULING = 56;
// PROBLEM_TYPE
SIMPLE_NUMERIC_PLANNING = 30;
GENERAL_NUMERIC_PLANNING = 31;
Expand Down Expand Up @@ -563,8 +614,11 @@ enum Feature {
DECREASE_EFFECTS = 16;
STATIC_FLUENTS_IN_BOOLEAN_ASSIGNMENTS = 41;
STATIC_FLUENTS_IN_NUMERIC_ASSIGNMENTS = 42;
STATIC_FLUENTS_IN_OBJECT_ASSIGNMENTS = 57;
FLUENTS_IN_BOOLEAN_ASSIGNMENTS = 43;
FLUENTS_IN_NUMERIC_ASSIGNMENTS = 44;
FLUENTS_IN_OBJECT_ASSIGNMENTS = 58;
FORALL_EFFECTS = 59;
// TYPING
FLAT_TYPING = 17;
HIERARCHICAL_TYPING = 18;
Expand Down Expand Up @@ -622,7 +676,6 @@ message ActionInstance {
// End time of the action. The default 0 value is OK in the case of non-temporal planning
// feature: [DURATIVE_ACTIONS]
Real end_time = 5;

}

message MethodInstance {
Expand All @@ -644,18 +697,22 @@ message PlanHierarchy {

// Instances of all methods used in the plan.
repeated MethodInstance methods = 2;

}

message Plan {
// An ordered sequence of actions that appear in the plan.
// The order of the actions in the list must be compatible with the partial order of the start times.
// In case of non-temporal planning, this allows having all start time at 0 and only rely on the order in this sequence.
// features: ACTION_BASED
repeated ActionInstance actions = 1;

// When the plan is hierarchical, this object provides the decomposition of hte root tasks into the actions of the plan
// feature: HIERARCHY
PlanHierarchy hierarchy = 2;

// Solution representation of a scheduling problem.
// feature: SCHEDULING
Schedule schedule = 3;
}


Expand Down
83 changes: 81 additions & 2 deletions planning/grpc/api/src/unified_planning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ pub struct EffectExpression {
/// features: CONDITIONAL_EFFECT
#[prost(message, optional, tag = "4")]
pub condition: ::core::option::Option<Expression>,
/// The variables that quantify this effect
#[prost(message, repeated, tag = "5")]
pub forall: ::prost::alloc::vec::Vec<Expression>,
}
/// Nested message and enum types in `EffectExpression`.
pub mod effect_expression {
Expand Down Expand Up @@ -452,6 +455,57 @@ pub struct Hierarchy {
#[prost(message, optional, tag = "3")]
pub initial_task_network: ::core::option::Option<TaskNetwork>,
}
/// Activity in a scheduling problem.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Activity {
/// Name of the activity that must uniquely identify it.
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
/// Typed and named parameters of the activity.
#[prost(message, repeated, tag = "2")]
pub parameters: ::prost::alloc::vec::Vec<Parameter>,
/// Duration of the activity
#[prost(message, optional, tag = "3")]
pub duration: ::core::option::Option<Duration>,
/// Conjunction of conditions that must hold if the activity is present.
#[prost(message, repeated, tag = "4")]
pub conditions: ::prost::alloc::vec::Vec<Condition>,
/// Conjunction of effects that this activity produces.
#[prost(message, repeated, tag = "5")]
pub effects: ::prost::alloc::vec::Vec<Effect>,
/// Conjunction of static constraints that must hold if the activity is present.
#[prost(message, repeated, tag = "6")]
pub constraints: ::prost::alloc::vec::Vec<Expression>,
}
/// Extension of `Problem` for scheduling
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SchedulingExtension {
/// All potential activities of the scheduling problem.
#[prost(message, repeated, tag = "1")]
pub activities: ::prost::alloc::vec::Vec<Activity>,
/// All variables in the base problem
#[prost(message, repeated, tag = "2")]
pub variables: ::prost::alloc::vec::Vec<Parameter>,
/// All constraints in the base problem.
#[prost(message, repeated, tag = "5")]
pub constraints: ::prost::alloc::vec::Vec<Expression>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Schedule {
/// Name of the activities that appear in the solution
#[prost(string, repeated, tag = "1")]
pub activities: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// Assignment of all variables and activity parameters and timepoints
/// that appear in the solution.
#[prost(map = "string, message", tag = "2")]
pub variable_assignments: ::std::collections::HashMap<
::prost::alloc::string::String,
Atom,
>,
}
/// A Goal is currently an expression that must hold either:
/// - in the final state,
/// - over a specific temporal interval (under the `timed_goals` features)
Expand Down Expand Up @@ -619,7 +673,6 @@ pub mod metric {
}
}
}
/// features: ACTION_BASED
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Problem {
Expand All @@ -634,6 +687,7 @@ pub struct Problem {
#[prost(message, repeated, tag = "5")]
pub objects: ::prost::alloc::vec::Vec<ObjectDeclaration>,
/// List of actions in the domain.
/// features: ACTION_BASED
#[prost(message, repeated, tag = "6")]
pub actions: ::prost::alloc::vec::Vec<Action>,
/// Initial state, including default values of state variables.
Expand All @@ -653,9 +707,13 @@ pub struct Problem {
#[prost(message, repeated, tag = "11")]
pub metrics: ::prost::alloc::vec::Vec<Metric>,
/// If the problem is hierarchical, defines the tasks and methods as well as the initial task network.
/// features: hierarchical
/// features: HIERARCHICAL
#[prost(message, optional, tag = "12")]
pub hierarchy: ::core::option::Option<Hierarchy>,
/// Scheduling-specific extension of the problem.
/// features: SCHEDULING
#[prost(message, optional, tag = "17")]
pub scheduling_extension: ::core::option::Option<SchedulingExtension>,
/// Trajectory constraints of the planning problem.
#[prost(message, repeated, tag = "13")]
pub trajectory_constraints: ::prost::alloc::vec::Vec<Expression>,
Expand Down Expand Up @@ -729,12 +787,17 @@ pub struct Plan {
/// An ordered sequence of actions that appear in the plan.
/// The order of the actions in the list must be compatible with the partial order of the start times.
/// In case of non-temporal planning, this allows having all start time at 0 and only rely on the order in this sequence.
/// features: ACTION_BASED
#[prost(message, repeated, tag = "1")]
pub actions: ::prost::alloc::vec::Vec<ActionInstance>,
/// When the plan is hierarchical, this object provides the decomposition of hte root tasks into the actions of the plan
/// feature: HIERARCHY
#[prost(message, optional, tag = "2")]
pub hierarchy: ::core::option::Option<PlanHierarchy>,
/// Solution representation of a scheduling problem.
/// feature: SCHEDULING
#[prost(message, optional, tag = "3")]
pub schedule: ::core::option::Option<Schedule>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
Expand Down Expand Up @@ -1114,6 +1177,7 @@ pub enum Feature {
/// PROBLEM_CLASS
ActionBased = 0,
Hierarchical = 26,
Scheduling = 56,
/// PROBLEM_TYPE
SimpleNumericPlanning = 30,
GeneralNumericPlanning = 31,
Expand Down Expand Up @@ -1145,8 +1209,11 @@ pub enum Feature {
DecreaseEffects = 16,
StaticFluentsInBooleanAssignments = 41,
StaticFluentsInNumericAssignments = 42,
StaticFluentsInObjectAssignments = 57,
FluentsInBooleanAssignments = 43,
FluentsInNumericAssignments = 44,
FluentsInObjectAssignments = 58,
ForallEffects = 59,
/// TYPING
FlatTyping = 17,
HierarchicalTyping = 18,
Expand Down Expand Up @@ -1192,6 +1259,7 @@ impl Feature {
match self {
Feature::ActionBased => "ACTION_BASED",
Feature::Hierarchical => "HIERARCHICAL",
Feature::Scheduling => "SCHEDULING",
Feature::SimpleNumericPlanning => "SIMPLE_NUMERIC_PLANNING",
Feature::GeneralNumericPlanning => "GENERAL_NUMERIC_PLANNING",
Feature::ContinuousTime => "CONTINUOUS_TIME",
Expand Down Expand Up @@ -1223,8 +1291,13 @@ impl Feature {
Feature::StaticFluentsInNumericAssignments => {
"STATIC_FLUENTS_IN_NUMERIC_ASSIGNMENTS"
}
Feature::StaticFluentsInObjectAssignments => {
"STATIC_FLUENTS_IN_OBJECT_ASSIGNMENTS"
}
Feature::FluentsInBooleanAssignments => "FLUENTS_IN_BOOLEAN_ASSIGNMENTS",
Feature::FluentsInNumericAssignments => "FLUENTS_IN_NUMERIC_ASSIGNMENTS",
Feature::FluentsInObjectAssignments => "FLUENTS_IN_OBJECT_ASSIGNMENTS",
Feature::ForallEffects => "FORALL_EFFECTS",
Feature::FlatTyping => "FLAT_TYPING",
Feature::HierarchicalTyping => "HIERARCHICAL_TYPING",
Feature::NumericFluents => "NUMERIC_FLUENTS",
Expand Down Expand Up @@ -1259,6 +1332,7 @@ impl Feature {
match value {
"ACTION_BASED" => Some(Self::ActionBased),
"HIERARCHICAL" => Some(Self::Hierarchical),
"SCHEDULING" => Some(Self::Scheduling),
"SIMPLE_NUMERIC_PLANNING" => Some(Self::SimpleNumericPlanning),
"GENERAL_NUMERIC_PLANNING" => Some(Self::GeneralNumericPlanning),
"CONTINUOUS_TIME" => Some(Self::ContinuousTime),
Expand Down Expand Up @@ -1290,8 +1364,13 @@ impl Feature {
"STATIC_FLUENTS_IN_NUMERIC_ASSIGNMENTS" => {
Some(Self::StaticFluentsInNumericAssignments)
}
"STATIC_FLUENTS_IN_OBJECT_ASSIGNMENTS" => {
Some(Self::StaticFluentsInObjectAssignments)
}
"FLUENTS_IN_BOOLEAN_ASSIGNMENTS" => Some(Self::FluentsInBooleanAssignments),
"FLUENTS_IN_NUMERIC_ASSIGNMENTS" => Some(Self::FluentsInNumericAssignments),
"FLUENTS_IN_OBJECT_ASSIGNMENTS" => Some(Self::FluentsInObjectAssignments),
"FORALL_EFFECTS" => Some(Self::ForallEffects),
"FLAT_TYPING" => Some(Self::FlatTyping),
"HIERARCHICAL_TYPING" => Some(Self::HierarchicalTyping),
"NUMERIC_FLUENTS" => Some(Self::NumericFluents),
Expand Down
6 changes: 5 additions & 1 deletion planning/grpc/server/src/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,11 @@ pub fn serialize_plan(
} else {
None
};
Ok(up::Plan { actions, hierarchy })
Ok(up::Plan {
actions,
hierarchy,
schedule: None,
})
}

fn rational_to_real(r: num_rational::Rational64) -> up::Real {
Expand Down
2 changes: 1 addition & 1 deletion planning/unified/deps/unified-planning
Submodule unified-planning updated 243 files
9 changes: 7 additions & 2 deletions planning/unified/plugin/up_aries/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,13 @@
# "CONDITIONAL_EFFECTS",
# "INCREASE_EFFECTS",
# "DECREASE_EFFECTS",
# "FORALL_EFFECTS",
"STATIC_FLUENTS_IN_BOOLEAN_ASSIGNMENTS",
"STATIC_FLUENTS_IN_NUMERIC_ASSIGNMENTS",
"STATIC_FLUENTS_IN_OBJECT_ASSIGNMENTS",
"FLUENTS_IN_BOOLEAN_ASSIGNMENTS",
"FLUENTS_IN_NUMERIC_ASSIGNMENTS",
"FLUENTS_IN_OBJECT_ASSIGNMENTS",
# TYPING
"FLAT_TYPING",
"HIERARCHICAL_TYPING",
Expand Down Expand Up @@ -139,10 +142,13 @@
"CONDITIONAL_EFFECTS",
"INCREASE_EFFECTS",
"DECREASE_EFFECTS",
# "FORALL_EFFECTS",
"STATIC_FLUENTS_IN_BOOLEAN_ASSIGNMENTS",
"STATIC_FLUENTS_IN_NUMERIC_ASSIGNMENTS",
"STATIC_FLUENTS_IN_OBJECT_ASSIGNMENTS",
"FLUENTS_IN_BOOLEAN_ASSIGNMENTS",
"FLUENTS_IN_NUMERIC_ASSIGNMENTS",
"FLUENTS_IN_OBJECT_ASSIGNMENTS",
# TYPING
"FLAT_TYPING",
"HIERARCHICAL_TYPING",
Expand Down Expand Up @@ -225,13 +231,12 @@ def _compile(self) -> str:
aries_build_cmd = "cargo build --profile ci --bin up-server"
print(f"Compiling Aries ({aries_path}) ...")
with open(os.devnull, "w", encoding="utf-8") as stdout:
build = subprocess.Popen(
subprocess.run(
aries_build_cmd,
shell=True,
cwd=aries_path,
stdout=stdout,
)
build.wait()
_ARIES_PREVIOUSLY_COMPILED = True
return aries_exe.as_posix()

Expand Down
Loading

0 comments on commit ca09acb

Please sign in to comment.