#[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 fn new(model: u8, startup: f64, shutdown: f64, coeffs: Vec<f64>) -> GenCost
pub fn new(model: u8, startup: f64, shutdown: f64, coeffs: Vec<f64>) -> GenCost
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>, ) -> GenCost
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.