Skip to main content

CostModel

Trait CostModel 

Source
pub trait CostModel: Send + Sync {
    // Required methods
    fn gate_cost(&self, gate: &dyn GateOp) -> f64;
    fn circuit_cost_from_gates(&self, gates: &[Box<dyn GateOp>]) -> f64;
    fn weights(&self) -> CostWeights;
    fn is_native(&self, gate: &dyn GateOp) -> bool;

    // Provided method
    fn gates_cost(&self, gates: &[Box<dyn GateOp>]) -> f64 { ... }
}
Expand description

Trait for cost models

Required Methods§

Source

fn gate_cost(&self, gate: &dyn GateOp) -> f64

Calculate the cost of a single gate

Source

fn circuit_cost_from_gates(&self, gates: &[Box<dyn GateOp>]) -> f64

Calculate the total cost of a circuit (using gate list)

Source

fn weights(&self) -> CostWeights

Get the weights used in cost calculation

Source

fn is_native(&self, gate: &dyn GateOp) -> bool

Check if a gate is native on the target hardware

Provided Methods§

Source

fn gates_cost(&self, gates: &[Box<dyn GateOp>]) -> f64

Calculate the total cost of a list of gates (alias for circuit_cost_from_gates)

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§