68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
/// Some parameter has an invalid value.
Parameter(msg: String) {
description("Parameter error")
display("Parameter error: {}", msg)
}
}
}
/// Result type for solvers.
pub type Result<T> = result::Result<T, Error>;
|
>
>
>
>
>
>
>
>
>
>
>
|
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
/// Some parameter has an invalid value.
Parameter(msg: String) {
description("Parameter error")
display("Parameter error: {}", msg)
}
/// The lower bound of a variable is larger than the upper bound.
InvalidBounds(lower: Real, upper: Real) {
description("invalid bounds")
display("Invalid bounds, lower:{} upper:{}", lower, upper)
}
/// The value of a variable is outside its bounds.
ViolatedBounds(lower: Real, upper: Real, value: Real) {
description("violated bounds")
display("Violated bounds, lower:{} upper:{} value:{}", lower, upper, value)
}
}
}
/// Result type for solvers.
pub type Result<T> = result::Result<T, Error>;
|
503
504
505
506
507
508
509
510
511
512
513
514
515
516
|
}
let lb = self.problem.lower_bounds().map(|x| x.to_dense());
let ub = self.problem.upper_bounds().map(|x| x.to_dense());
for i in 0..self.cur_y.len() {
let lb_i = lb.as_ref().map(|x| x[i]).unwrap_or(NEG_INFINITY);
let ub_i = ub.as_ref().map(|x| x[i]).unwrap_or(INFINITY);
if self.cur_y[i] < lb_i {
self.cur_valid = false;
self.cur_y[i] = lb_i;
} else if self.cur_y[i] > ub_i {
self.cur_valid = false;
self.cur_y[i] = ub_i;
}
|
>
|
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
|
}
let lb = self.problem.lower_bounds().map(|x| x.to_dense());
let ub = self.problem.upper_bounds().map(|x| x.to_dense());
for i in 0..self.cur_y.len() {
let lb_i = lb.as_ref().map(|x| x[i]).unwrap_or(NEG_INFINITY);
let ub_i = ub.as_ref().map(|x| x[i]).unwrap_or(INFINITY);
if lb_i > ub_i { return Err(Error::InvalidBounds(lb_i, ub_i)); }
if self.cur_y[i] < lb_i {
self.cur_valid = false;
self.cur_y[i] = lb_i;
} else if self.cur_y[i] > ub_i {
self.cur_valid = false;
self.cur_y[i] = ub_i;
}
|
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
|
}
};
let mut newvars = Vec::with_capacity(updates.len());
for u in updates {
match u {
Update::AddVariable{lower, upper} => {
newvars.push((lower, upper));
},
}
}
if !newvars.is_empty() {
let mut problem = &mut self.problem;
let minorants = &self.minorants;
|
>
>
>
>
>
>
|
|
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
|
}
};
let mut newvars = Vec::with_capacity(updates.len());
for u in updates {
match u {
Update::AddVariable{lower, upper} => {
if lower > upper {
return Err(Error::InvalidBounds(lower, upper))
}
let value = if lower > 0.0 { lower }
else if upper < 0.0 { upper }
else { 0.0 };
newvars.push((lower - value, upper - value));
},
}
}
if !newvars.is_empty() {
let mut problem = &mut self.problem;
let minorants = &self.minorants;
|