#[non_exhaustive]pub struct GenCost {
pub model: u8,
pub startup: f64,
pub shutdown: f64,
pub ncost: usize,
pub coeffs: Vec<f64>,
}Expand description
A generator cost curve (mpc.gencost row).
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.model: u81 = piecewise linear, 2 = polynomial.
startup: f64§shutdown: f64§ncost: usizeNumber of cost coefficients (polynomial) or breakpoints (piecewise).
coeffs: Vec<f64>Raw coefficients, highest order first for the polynomial model:
[c_{k-1}, …, c1, c0].
Implementations§
Source§impl GenCost
impl GenCost
Sourcepub const LEADING_COEFF_TOL: f64 = 1e-12
pub const LEADING_COEFF_TOL: f64 = 1e-12
Largest leading polynomial coefficient that
quadratic_with_constant_tol
reads as a rounding artifact of the source, not as a term of the curve.
Sourcepub fn new(model: u8, startup: f64, shutdown: f64, coeffs: Vec<f64>) -> Self
pub fn new(model: u8, startup: f64, shutdown: f64, coeffs: Vec<f64>) -> Self
Build a cost row from the values carried after ncost.
Polynomial rows (model == 2) store ncost coefficients. Piecewise
linear rows (model == 1) store flattened (x, y) breakpoint pairs, so
ncost is half the coefficient count. Use GenCost::with_ncost for
malformed source rows or callers that need to preserve an explicit
ncost.
pub fn with_ncost( model: u8, startup: f64, shutdown: f64, ncost: usize, coeffs: Vec<f64>, ) -> Self
Sourcepub fn quadratic(&self) -> Option<(f64, f64)>
pub fn quadratic(&self) -> Option<(f64, f64)>
(q, c) for the quadratic cost ½ q p² + c p from a polynomial
(model 2) row. MATPOWER stores c2 p² + c1 p + c0, so q = 2·c2 and
c = c1. Linear rows (ncost == 2) give q = 0. Piecewise (model 1)
or cubic and higher return None.
Sourcepub fn quadratic_with_constant(&self) -> Option<(f64, f64, f64)>
pub fn quadratic_with_constant(&self) -> Option<(f64, f64, f64)>
(q, c, c0) for the quadratic cost ½ q p² + c p + c0 from a
polynomial (model 2) row, keeping the constant term that
quadratic drops. Linear rows (ncost == 2) give
q = 0; constant rows (ncost == 1) give q = c = 0. Piecewise
(model 1) or cubic and higher return None.
Sourcepub fn quadratic_with_constant_tol(&self, tol: f64) -> Option<(f64, f64, f64)>
pub fn quadratic_with_constant_tol(&self, tol: f64) -> Option<(f64, f64, f64)>
(q, c, c0) as quadratic_with_constant
gives it, after the leading coefficients at or below tol come off the
row.
A model 2 row often carries a leading coefficient near 1e-17, which
the source produced by rounding. Such a row states a linear curve and
reads as a quadratic one. Pass
LEADING_COEFF_TOL to strip the artifact,
or 0.0 to strip an exact zero alone.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for GenCost
impl<'de> Deserialize<'de> for GenCost
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>,
Source§impl From<&GenCost> for SolverCostRow
impl From<&GenCost> for SolverCostRow
Source§impl JsonSchema for GenCost
impl JsonSchema for GenCost
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read more