pub struct BilevelProblem<F, G>{
pub upper_obj: F,
pub lower_obj: G,
pub x0: Vec<f64>,
pub y0: Vec<f64>,
pub upper_constraints: Vec<Box<dyn Fn(&[f64], &[f64]) -> f64>>,
pub lower_constraints: Vec<Box<dyn Fn(&[f64], &[f64]) -> f64>>,
pub x_lb: Option<Vec<f64>>,
pub x_ub: Option<Vec<f64>>,
pub y_lb: Option<Vec<f64>>,
pub y_ub: Option<Vec<f64>>,
}Expand description
Bilevel problem descriptor
Encapsulates upper and lower level objectives and optional constraints.
Fields§
§upper_obj: FUpper-level objective F(x, y)
lower_obj: GLower-level objective f(x, y)
x0: Vec<f64>Initial upper-level variables
y0: Vec<f64>Initial lower-level variables
upper_constraints: Vec<Box<dyn Fn(&[f64], &[f64]) -> f64>>Upper-level inequality constraints G_i(x,y) <= 0
lower_constraints: Vec<Box<dyn Fn(&[f64], &[f64]) -> f64>>Lower-level inequality constraints g_j(x,y) <= 0
x_lb: Option<Vec<f64>>Optional lower bounds on x
x_ub: Option<Vec<f64>>Optional upper bounds on x
y_lb: Option<Vec<f64>>Optional lower bounds on y
y_ub: Option<Vec<f64>>Optional upper bounds on y
Implementations§
Source§impl<F, G> BilevelProblem<F, G>
impl<F, G> BilevelProblem<F, G>
Sourcepub fn new(upper_obj: F, lower_obj: G, x0: Vec<f64>, y0: Vec<f64>) -> Self
pub fn new(upper_obj: F, lower_obj: G, x0: Vec<f64>, y0: Vec<f64>) -> Self
Create a new bilevel problem with no constraints
Sourcepub fn with_upper_constraint(
self,
constraint: impl Fn(&[f64], &[f64]) -> f64 + 'static,
) -> Self
pub fn with_upper_constraint( self, constraint: impl Fn(&[f64], &[f64]) -> f64 + 'static, ) -> Self
Add an upper-level inequality constraint G(x,y) <= 0
Sourcepub fn with_lower_constraint(
self,
constraint: impl Fn(&[f64], &[f64]) -> f64 + 'static,
) -> Self
pub fn with_lower_constraint( self, constraint: impl Fn(&[f64], &[f64]) -> f64 + 'static, ) -> Self
Add a lower-level inequality constraint g(x,y) <= 0
Sourcepub fn with_x_bounds(self, lb: Vec<f64>, ub: Vec<f64>) -> Self
pub fn with_x_bounds(self, lb: Vec<f64>, ub: Vec<f64>) -> Self
Set bounds on upper-level variables
Sourcepub fn with_y_bounds(self, lb: Vec<f64>, ub: Vec<f64>) -> Self
pub fn with_y_bounds(self, lb: Vec<f64>, ub: Vec<f64>) -> Self
Set bounds on lower-level variables
Sourcepub fn eval_upper(&self, x: &[f64], y: &[f64]) -> f64
pub fn eval_upper(&self, x: &[f64], y: &[f64]) -> f64
Evaluate upper objective
Sourcepub fn eval_lower(&self, x: &[f64], y: &[f64]) -> f64
pub fn eval_lower(&self, x: &[f64], y: &[f64]) -> f64
Evaluate lower objective
Sourcepub fn upper_constraint_violation(&self, x: &[f64], y: &[f64]) -> f64
pub fn upper_constraint_violation(&self, x: &[f64], y: &[f64]) -> f64
Compute upper constraint violation (sum of max(0, G_i))
Sourcepub fn lower_constraint_violation(&self, x: &[f64], y: &[f64]) -> f64
pub fn lower_constraint_violation(&self, x: &[f64], y: &[f64]) -> f64
Compute lower constraint violation (sum of max(0, g_j))
Auto Trait Implementations§
impl<F, G> Freeze for BilevelProblem<F, G>
impl<F, G> !RefUnwindSafe for BilevelProblem<F, G>
impl<F, G> !Send for BilevelProblem<F, G>
impl<F, G> !Sync for BilevelProblem<F, G>
impl<F, G> Unpin for BilevelProblem<F, G>
impl<F, G> UnsafeUnpin for BilevelProblem<F, G>where
F: UnsafeUnpin,
G: UnsafeUnpin,
impl<F, G> !UnwindSafe for BilevelProblem<F, G>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.