Skip to content

Commit

Permalink
Apply minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
reinterpretcat committed Dec 12, 2023
1 parent 9159a24 commit a29ddf8
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions vrp-pragmatic/src/format/problem/goal_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,21 +87,7 @@ fn get_objective_features(
blocks: &ProblemBlocks,
props: &ProblemProperties,
) -> Result<Vec<Vec<Feature>>, GenericError> {
let objectives = if let Some(objectives) = api_problem.objectives.clone() {
objectives
} else {
let mut objectives = vec![
vec![Objective::MinimizeUnassigned { breaks: Some(1.) }],
vec![Objective::MinimizeTours],
vec![Objective::MinimizeCost],
];

if props.has_value {
objectives.insert(0, vec![Objective::MaximizeValue { breaks: None }])
}

objectives
};
let objectives = get_objectives(api_problem, props);

objectives
.iter()
Expand Down Expand Up @@ -231,6 +217,24 @@ fn get_objective_features(
.collect()
}

fn get_objectives(api_problem: &ApiProblem, props: &ProblemProperties) -> Vec<Vec<Objective>> {
if let Some(objectives) = api_problem.objectives.clone() {
objectives
} else {
let mut objectives = vec![
vec![Objective::MinimizeUnassigned { breaks: Some(1.) }],
vec![Objective::MinimizeTours],
vec![Objective::MinimizeCost],
];

if props.has_value {
objectives.insert(0, vec![Objective::MaximizeValue { breaks: None }])
}

objectives
}
}

const RELOAD_THRESHOLD: f64 = 0.9;

fn get_capacity_feature(
Expand Down

0 comments on commit a29ddf8

Please sign in to comment.