small things
This commit is contained in:
@@ -122,6 +122,7 @@ impl<'a,V, K: Eq + Hash + Clone> Problem<'a, V, K> {
|
||||
if let Some(mut init_updates) = self._push_updates() {
|
||||
stack.append(&mut init_updates);
|
||||
} else {
|
||||
// Solution is complete
|
||||
panic!("Could not initialize !");
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user