pub struct ScoreFunction {
pub tc_weight: f64,
pub sc_weight: f64,
pub rw_weight: f64,
pub sc_target: f64,
}Expand description
Weighted scoring function for contraction quality evaluation.
The score is computed as:
score = tc_weight * 2^tc + rw_weight * 2^rw + sc_weight * max(0, 2^sc - 2^sc_target)Where:
tcis the time complexity (log2 of FLOP count)scis the space complexity (log2 of max intermediate tensor size)rwis the read-write complexity (log2 of total I/O operations)
§Example
use omeco::ScoreFunction;
let score = ScoreFunction::default();
let result = score.evaluate(10.0, 5.0, 8.0);Fields§
§tc_weight: f64Weight for time complexity (default: 1.0)
sc_weight: f64Weight for space complexity penalty (default: 1.0)
rw_weight: f64Weight for read-write complexity (default: 0.0)
sc_target: f64Target space complexity threshold (default: 20.0) Space complexity is only penalized if it exceeds this target.
Implementations§
Source§impl ScoreFunction
impl ScoreFunction
Sourcepub fn new(
tc_weight: f64,
sc_weight: f64,
rw_weight: f64,
sc_target: f64,
) -> Self
pub fn new( tc_weight: f64, sc_weight: f64, rw_weight: f64, sc_target: f64, ) -> Self
Create a new ScoreFunction with custom weights.
Sourcepub fn time_optimized() -> Self
pub fn time_optimized() -> Self
Create a score function optimizing primarily for time complexity.
Sourcepub fn space_optimized(sc_target: f64) -> Self
pub fn space_optimized(sc_target: f64) -> Self
Create a score function optimizing primarily for space complexity.
Sourcepub fn exceeds_target(&self, sc: f64) -> bool
pub fn exceeds_target(&self, sc: f64) -> bool
Check if space complexity exceeds the target.
Sourcepub fn with_sc_target(self, sc_target: f64) -> Self
pub fn with_sc_target(self, sc_target: f64) -> Self
Builder method to set the space complexity target.
Sourcepub fn with_tc_weight(self, tc_weight: f64) -> Self
pub fn with_tc_weight(self, tc_weight: f64) -> Self
Builder method to set the time complexity weight.
Sourcepub fn with_sc_weight(self, sc_weight: f64) -> Self
pub fn with_sc_weight(self, sc_weight: f64) -> Self
Builder method to set the space complexity weight.
Sourcepub fn with_rw_weight(self, rw_weight: f64) -> Self
pub fn with_rw_weight(self, rw_weight: f64) -> Self
Builder method to set the read-write complexity weight.
Trait Implementations§
Source§impl Clone for ScoreFunction
impl Clone for ScoreFunction
Source§fn clone(&self) -> ScoreFunction
fn clone(&self) -> ScoreFunction
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ScoreFunction
impl Debug for ScoreFunction
Source§impl Default for ScoreFunction
impl Default for ScoreFunction
Source§impl<'de> Deserialize<'de> for ScoreFunction
impl<'de> Deserialize<'de> for ScoreFunction
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for ScoreFunction
impl RefUnwindSafe for ScoreFunction
impl Send for ScoreFunction
impl Sync for ScoreFunction
impl Unpin for ScoreFunction
impl UnwindSafe for ScoreFunction
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 more