pub struct ObjectiveSpec {
pub key: ObjectiveKey,
pub direction: ObjectiveDirection,
pub units: Option<String>,
pub description: Option<String>,
pub target: Option<f64>,
pub min_value: Option<f64>,
pub max_value: Option<f64>,
}Expand description
Specification for an optimization objective.
Fields§
§key: ObjectiveKeyKey identifying the objective metric.
direction: ObjectiveDirectionWhether to maximize or minimize this objective.
units: Option<String>Optional units (e.g., “ms”, “usd”, “tokens”).
description: Option<String>Human-readable description.
target: Option<f64>Target value (for constrained optimization).
min_value: Option<f64>Minimum acceptable value.
max_value: Option<f64>Maximum acceptable value.
Implementations§
Source§impl ObjectiveSpec
impl ObjectiveSpec
Sourcepub fn new(key: ObjectiveKey, direction: ObjectiveDirection) -> ObjectiveSpec
pub fn new(key: ObjectiveKey, direction: ObjectiveDirection) -> ObjectiveSpec
Create a new objective spec.
Sourcepub fn maximize_reward() -> ObjectiveSpec
pub fn maximize_reward() -> ObjectiveSpec
Create a reward maximization objective.
Sourcepub fn minimize_cost() -> ObjectiveSpec
pub fn minimize_cost() -> ObjectiveSpec
Create a cost minimization objective.
Sourcepub fn minimize_latency() -> ObjectiveSpec
pub fn minimize_latency() -> ObjectiveSpec
Create a latency minimization objective.
Sourcepub fn with_units(self, units: impl Into<String>) -> ObjectiveSpec
pub fn with_units(self, units: impl Into<String>) -> ObjectiveSpec
Set units for this objective.
Sourcepub fn with_description(self, desc: impl Into<String>) -> ObjectiveSpec
pub fn with_description(self, desc: impl Into<String>) -> ObjectiveSpec
Set description for this objective.
Sourcepub fn satisfies_constraints(&self, value: f64) -> bool
pub fn satisfies_constraints(&self, value: f64) -> bool
Check if a value satisfies the objective’s constraints.
Trait Implementations§
Source§impl Clone for ObjectiveSpec
impl Clone for ObjectiveSpec
Source§fn clone(&self) -> ObjectiveSpec
fn clone(&self) -> ObjectiveSpec
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ObjectiveSpec
impl Debug for ObjectiveSpec
Source§impl<'de> Deserialize<'de> for ObjectiveSpec
impl<'de> Deserialize<'de> for ObjectiveSpec
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ObjectiveSpec, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ObjectiveSpec, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for ObjectiveSpec
impl Serialize for ObjectiveSpec
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for ObjectiveSpec
impl RefUnwindSafe for ObjectiveSpec
impl Send for ObjectiveSpec
impl Sync for ObjectiveSpec
impl Unpin for ObjectiveSpec
impl UnwindSafe for ObjectiveSpec
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request