Enum DemandCurve

Source
pub enum DemandCurve {
    Pwl(PwlCurve),
    Constant(ConstantCurve),
}
Expand description

A demand curve expressing a bidder’s willingness to pay at different rates.

The solver uses these curves to find optimal allocations that maximize total welfare. All curves must include rate=0 in their domain to allow for zero trade scenarios.

Variants§

§

Pwl(PwlCurve)

Piecewise linear curve defined by a series of points

§

Constant(ConstantCurve)

Constant price curve over a rate interval

Implementations§

Source§

impl DemandCurve

Source

pub unsafe fn new_unchecked(value: DemandCurveDto) -> Self

Creates a demand curve without validation

§Safety

The caller must ensure the data represents a valid curve. Invalid curves may cause undefined behavior in the solver.

Source

pub fn domain(&self) -> (f64, f64)

Returns the rate interval over which this curve is defined

§Returns

A tuple (min_rate, max_rate) defining the valid rate range for this curve.

Source

pub fn points(self) -> Vec<Point>

Converts the curve into a vector of points

For PWL curves, returns all defining points. For constant curves, returns two points representing the endpoints of the constant price segment.

Trait Implementations§

Source§

impl Clone for DemandCurve

Source§

fn clone(&self) -> DemandCurve

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DemandCurve

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<ConstantCurve> for DemandCurve

Source§

fn from(value: ConstantCurve) -> Self

Converts to this type from the input type.
Source§

impl From<PwlCurve> for DemandCurve

Source§

fn from(value: PwlCurve) -> Self

Converts to this type from the input type.
Source§

impl Into<DemandCurveDto> for DemandCurve

Source§

fn into(self) -> DemandCurveDto

Converts this type into the (usually inferred) input type.
Source§

impl TryFrom<ConstantCurveDto> for DemandCurve

Source§

type Error = ConstantCurveError

The type returned in the event of a conversion error.
Source§

fn try_from(value: ConstantCurveDto) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<DemandCurveDto> for DemandCurve

Source§

fn try_from(value: DemandCurveDto) -> Result<Self, Self::Error>

Creates a demand curve from a DTO, validating all constraints

Source§

type Error = DemandCurveError

The type returned in the event of a conversion error.
Source§

impl TryFrom<PwlCurveDto> for DemandCurve

Source§

type Error = PwlCurveError

The type returned in the event of a conversion error.
Source§

fn try_from(value: PwlCurveDto) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.