Skip to content

Commit

Permalink
feat: Allow specifying solver strategies in up-server.
Browse files Browse the repository at this point in the history
  • Loading branch information
arbimo committed Dec 5, 2023
1 parent 270f1af commit 51bba79
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions planning/grpc/server/src/bin/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use aries_grpc_server::chronicles::problem_to_chronicles;
use aries_grpc_server::serialize::{engine, serialize_plan};
use aries_plan_validator::validate_upf;
use aries_planners::solver;
use aries_planners::solver::{Metric, SolverResult};
use aries_planners::solver::{Metric, SolverResult, Strat};
use aries_planning::chronicles::analysis::hierarchical_is_non_recursive;
use aries_planning::chronicles::FiniteProblem;
use async_trait::async_trait;
Expand Down Expand Up @@ -78,6 +78,12 @@ pub struct SolverConfiguration {
/// Maximal depth for the search.
#[clap(long, default_value = "4294967295")]
pub max_depth: u32,

/// If provided, the solver will only run the specified strategy instead of default set of strategies.
/// When repeated, several strategies will be run in parallel.
/// Allowed values: forward | activity | activity-no-time | causal
#[clap(long = "strategy", short = 's')]
strategies: Vec<Strat>,
}

impl Default for SolverConfiguration {
Expand All @@ -87,6 +93,7 @@ impl Default for SolverConfiguration {
timeout: None,
min_depth: 0,
max_depth: u32::MAX,
strategies: Vec::new(),
}
}
}
Expand Down Expand Up @@ -135,7 +142,6 @@ fn solve_blocking(
.timeout
.map(|timeout| reception_time + std::time::Duration::from_secs_f64(timeout));

let strategies = vec![];
let htn_mode = problem.hierarchy.is_some();

ensure!(problem.metrics.len() <= 1, "Unsupported: multiple metrics provided.");
Expand Down Expand Up @@ -176,7 +182,7 @@ fn solve_blocking(
base_problem,
min_depth,
max_depth,
&strategies,
&conf.strategies,
metric,
htn_mode,
on_new_solution,
Expand Down

0 comments on commit 51bba79

Please sign in to comment.