pub struct Online<P> {
pub p: P,
pub w: i32,
}
Expand description
Online instance of a problem.
Fields§
§p: P
Problem.
w: i32
Finite, non-negative prediction window.
This prediction window is included in the time bound of the problem instance, i.e. at time $t$ $t_end$ should be set to $t + w$.
Implementations§
Source§impl<'a, P> Online<P>where
P: DiscretizableProblem,
impl<'a, P> Online<P>where
P: DiscretizableProblem,
Source§impl<'a, P> Online<P>where
P: RelaxableProblem,
impl<'a, P> Online<P>where
P: RelaxableProblem,
Source§impl<'a, T> Online<SmoothedLoadOptimization<T>>where
T: Value<'a>,
impl<'a, T> Online<SmoothedLoadOptimization<T>>where
T: Value<'a>,
pub fn into_sblo(self) -> Online<SmoothedBalancedLoadOptimization<'a, T>>
Source§impl<'a, T> Online<SmoothedBalancedLoadOptimization<'a, T>>where
T: Value<'a>,
impl<'a, T> Online<SmoothedBalancedLoadOptimization<'a, T>>where
T: Value<'a>,
pub fn into_ssco( self, ) -> Online<SimplifiedSmoothedConvexOptimization<'a, T, DataCenterModelOutputSuccess, DataCenterModelOutputFailure>>
Source§impl<'a, T, C, D> Online<SimplifiedSmoothedConvexOptimization<'a, T, C, D>>where
T: Value<'a>,
C: ModelOutputSuccess + 'a,
D: ModelOutputFailure + 'a,
impl<'a, T, C, D> Online<SimplifiedSmoothedConvexOptimization<'a, T, C, D>>where
T: Value<'a>,
C: ModelOutputSuccess + 'a,
D: ModelOutputFailure + 'a,
pub fn into_sco(self) -> Online<SmoothedConvexOptimization<'a, T, C, D>>
Source§impl<'a, P> Online<P>
impl<'a, P> Online<P>
Sourcepub fn stream<T, M, O, C, D>(
&mut self,
alg: &impl OnlineAlgorithm<'a, T, P, M, O, C, D>,
update: impl Fn(&mut Online<P>, &Schedule<T>) -> bool,
options: O,
) -> Result<(Schedule<T>, Option<M>)>where
T: Value<'a>,
P: Problem<T, C, D> + 'a,
M: Memory<'a, T, P, C, D>,
O: Options<T, P, C, D>,
C: ModelOutputSuccess,
D: ModelOutputFailure,
pub fn stream<T, M, O, C, D>(
&mut self,
alg: &impl OnlineAlgorithm<'a, T, P, M, O, C, D>,
update: impl Fn(&mut Online<P>, &Schedule<T>) -> bool,
options: O,
) -> Result<(Schedule<T>, Option<M>)>where
T: Value<'a>,
P: Problem<T, C, D> + 'a,
M: Memory<'a, T, P, C, D>,
O: Options<T, P, C, D>,
C: ModelOutputSuccess,
D: ModelOutputFailure,
Utility to stream an online algorithm from $T = 1$.
Returns resulting schedule, final memory of the algorithm.
alg
- Online algorithm to stream.update
- Callback that in each iteration updates the problem instance. Returntrue
to continue stream,false
to end stream.options
- Algorithm options.
Sourcepub fn stream_from<T, M, O, C, D>(
&mut self,
alg: &impl OnlineAlgorithm<'a, T, P, M, O, C, D>,
update: impl Fn(&mut Online<P>, &Schedule<T>) -> bool,
options: O,
xs: &mut Schedule<T>,
prev_m: Option<M>,
) -> Result<Option<M>>where
T: Value<'a>,
P: Problem<T, C, D> + 'a,
M: Memory<'a, T, P, C, D>,
O: Options<T, P, C, D>,
C: ModelOutputSuccess,
D: ModelOutputFailure,
pub fn stream_from<T, M, O, C, D>(
&mut self,
alg: &impl OnlineAlgorithm<'a, T, P, M, O, C, D>,
update: impl Fn(&mut Online<P>, &Schedule<T>) -> bool,
options: O,
xs: &mut Schedule<T>,
prev_m: Option<M>,
) -> Result<Option<M>>where
T: Value<'a>,
P: Problem<T, C, D> + 'a,
M: Memory<'a, T, P, C, D>,
O: Options<T, P, C, D>,
C: ModelOutputSuccess,
D: ModelOutputFailure,
Stream an online algorithm from an arbitrary initial time, given the previous schedule and memory.
Returns final memory of the algorithm.
alg
- Online algorithm to stream.update
- Callback that in each iteration updates the problem instance. Returntrue
to continue stream,false
to end stream.options
- Algorithm options.xs
- Schedule.prev_m
- Memory of last iteration.
Sourcepub fn next<T, M, O, C, D>(
&self,
alg: &impl OnlineAlgorithm<'a, T, P, M, O, C, D>,
options: O,
xs: &mut Schedule<T>,
prev_m: Option<M>,
) -> Result<(Config<T>, Option<M>)>where
T: Value<'a>,
P: Problem<T, C, D> + 'a,
M: Memory<'a, T, P, C, D>,
O: Options<T, P, C, D>,
C: ModelOutputSuccess,
D: ModelOutputFailure,
pub fn next<T, M, O, C, D>(
&self,
alg: &impl OnlineAlgorithm<'a, T, P, M, O, C, D>,
options: O,
xs: &mut Schedule<T>,
prev_m: Option<M>,
) -> Result<(Config<T>, Option<M>)>where
T: Value<'a>,
P: Problem<T, C, D> + 'a,
M: Memory<'a, T, P, C, D>,
O: Options<T, P, C, D>,
C: ModelOutputSuccess,
D: ModelOutputFailure,
Executes one step of an online algorithm.
alg
- Online algorithm to stream.options
- Algorithm options.xs
- Schedule.prev_m
- Memory of last iteration.
Sourcepub fn offline_stream<T, M, O, C, D>(
&mut self,
alg: &impl OnlineAlgorithm<'a, T, P, M, O, C, D>,
t_end: i32,
options: O,
) -> Result<(Schedule<T>, Option<M>)>where
T: Value<'a>,
P: Problem<T, C, D> + 'a,
M: Memory<'a, T, P, C, D>,
O: Options<T, P, C, D>,
C: ModelOutputSuccess,
D: ModelOutputFailure,
pub fn offline_stream<T, M, O, C, D>(
&mut self,
alg: &impl OnlineAlgorithm<'a, T, P, M, O, C, D>,
t_end: i32,
options: O,
) -> Result<(Schedule<T>, Option<M>)>where
T: Value<'a>,
P: Problem<T, C, D> + 'a,
M: Memory<'a, T, P, C, D>,
O: Options<T, P, C, D>,
C: ModelOutputSuccess,
D: ModelOutputFailure,
Utility to stream an online algorithm with a constant cost function from $T = 1$.
Returns resulting schedule, final memory of the algorithm.
alg
- Online algorithm to stream.t_end
- Finite time horizon. $t_end \geq 1$.
Sourcepub fn offline_stream_from<T, M, O, C, D>(
&'a mut self,
alg: &impl OnlineAlgorithm<'a, T, P, M, O, C, D>,
t_end: i32,
options: O,
xs: &mut Schedule<T>,
prev_m: Option<M>,
) -> Result<Option<M>>where
T: Value<'a>,
P: Problem<T, C, D>,
M: Memory<'a, T, P, C, D>,
O: Options<T, P, C, D>,
C: ModelOutputSuccess,
D: ModelOutputFailure,
pub fn offline_stream_from<T, M, O, C, D>(
&'a mut self,
alg: &impl OnlineAlgorithm<'a, T, P, M, O, C, D>,
t_end: i32,
options: O,
xs: &mut Schedule<T>,
prev_m: Option<M>,
) -> Result<Option<M>>where
T: Value<'a>,
P: Problem<T, C, D>,
M: Memory<'a, T, P, C, D>,
O: Options<T, P, C, D>,
C: ModelOutputSuccess,
D: ModelOutputFailure,
Utility to stream an online algorithm with a constant cost function from an arbitrary initial time, given the previous schedule and memory.
Returns final memory of the algorithm.
alg
- Online algorithm to stream.t_end
- Finite time horizon. Must be greater or equals to the current time slot.xs
- Schedule.prev_m
- Memory of last iteration.
Trait Implementations§
Auto Trait Implementations§
impl<P> Freeze for Online<P>where
P: Freeze,
impl<P> RefUnwindSafe for Online<P>where
P: RefUnwindSafe,
impl<P> Send for Online<P>where
P: Send,
impl<P> Sync for Online<P>where
P: Sync,
impl<P> Unpin for Online<P>where
P: Unpin,
impl<P> UnwindSafe for Online<P>where
P: UnwindSafe,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.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.