Permalink
Browse files

[global constraints][bug] Ensure variable array of global constraints…

… are non-empty.
  • Loading branch information...
ptal committed Jul 23, 2018
1 parent 6a6e81b commit ef40b93e95f7d6477e453ce25759c1216358326f
Showing with 10 additions and 1 deletion.
  1. +1 −1 Cargo.toml
  2. +3 −0 src/libpcp/propagators/all_equal.rs
  3. +6 −0 src/libpcp/propagators/distinct.rs
View
@@ -1,7 +1,7 @@
[package]
name = "pcp"
version = "0.6.0"
version = "0.6.1"
authors = [ "Pierre Talbot <ptalbot@hyc.io>" ]
[lib]
@@ -42,7 +42,10 @@ impl<VStore, Domain, Bound> AllEqual<VStore> where
Domain: IntDomain<Item=Bound> + 'static,
Bound: IntBound + 'static,
{
/// Precondition: `vars.len() > 1`.
pub fn new(vars: Vec<Var<VStore>>) -> Self {
assert!(vars.len() > 0,
"Variable array in `AllEqual` must be non-empty.");
let mut props = vec![];
for i in 0..vars.len()-1 {
let i_eq_j = Box::new(XEqY::new(vars[i].bclone(), vars[i+1].bclone())) as Formula<VStore>;
@@ -22,13 +22,16 @@ use propagation::*;
use gcollections::*;
use concept::*;
/// Precondition: `vars.len() > 1`.
pub fn join_distinct<VStore, CStore, Domain, Bound>(
_vstore: &mut VStore, cstore: &mut CStore, vars: Vec<Var<VStore>>) where
VStore: VStoreConcept<Item=Domain> + 'static,
Domain: IntDomain<Item=Bound> + 'static,
Bound: IntBound + 'static,
CStore: IntCStore<VStore> + 'static
{
assert!(vars.len() > 0,
"Variable array in `Distinct` must be non-empty.");
for i in 0..vars.len()-1 {
for j in i+1..vars.len() {
cstore.alloc(Box::new(XNeqY::new(vars[i].bclone(), vars[j].bclone())));
@@ -56,7 +59,10 @@ impl<VStore, Domain, Bound> Distinct<VStore> where
Domain: IntDomain<Item=Bound> + 'static,
Bound: IntBound + 'static,
{
/// Precondition: `vars.len() > 1`.
pub fn new(vars: Vec<Var<VStore>>) -> Self {
assert!(vars.len() > 0,
"Variable array in `Distinct` must be non-empty.");
let mut props = vec![];
for i in 0..vars.len()-1 {
for j in i+1..vars.len() {

0 comments on commit ef40b93

Please sign in to comment.