Struct smoothed_online_convex_optimization::problem::Online [−][src]
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
pub fn into_ssco(
self
) -> Online<SimplifiedSmoothedConvexOptimization<'a, T, DataCenterModelOutputSuccess, DataCenterModelOutputFailure>>
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 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.
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,
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.
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,
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.
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,
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$.
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,
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> RefUnwindSafe for Online<P> where
P: RefUnwindSafe,
impl<P> UnwindSafe for Online<P> where
P: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
type Output = T
type Output = T
Should always be Self
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
pub fn is_in_subset(&self) -> bool
pub fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).
pub fn to_subset_unchecked(&self) -> SS
pub fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
pub fn from_subset(element: &SS) -> SP
pub fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
pub fn is_in_subset(&self) -> bool
pub fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).
pub fn to_subset_unchecked(&self) -> SS
pub fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
pub fn from_subset(element: &SS) -> SP
pub fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.