small things

This commit is contained in:
2019-02-14 14:36:44 +01:00
parent 3ee9533faf
commit 3e477945ea
2 changed files with 16 additions and 14 deletions

View File

@@ -136,19 +136,20 @@ mod api {
// Let's hack for now
// BUGGY because template does not generate every variables, needs refactoring
// Find variable in partial
let initial_id = partial.iter().find_map(|slot| {
if slot.value.is_none() { return None; };
//println!("{:?} vs {:?}", slot, var);
if slot.key.0 == var.0
&& slot.key.1 == format!("{:?}",var.1)
{
let id = slot.value.as_ref().unwrap().id;
println!("found initial : recipe with id {}", id);
return Some(id);
} else {
return None;
}
});
let initial_id = partial.iter()
.filter(|slot| slot.value.is_some())
.find_map(|slot| {
//println!("{:?} vs {:?}", slot, var);
if slot.key.0 == var.0
&& slot.key.1 == format!("{:?}",var.1)
{
let id = slot.value.as_ref().unwrap().id;
println!("found initial : recipe with id {}", id);
Some(id)
} else {
None
}
});
let ini = if let Some(id) = initial_id {
let new_ini = domain.values.iter().find(|r| r.id == id);
println!("Overrided {:?}", new_ini);
@@ -158,7 +159,7 @@ mod api {
};
// If found, override initial value
problem = problem.add_variable(var, dom, ini);
}
};
let mut problem = problem
.add_constraint(|_| true)
.finish();