fts_solver/
types.rs

1mod submission;
2pub use submission::*;
3
4mod spvec;
5pub(crate) use spvec::spvec;
6
7mod auth;
8pub use auth::*;
9
10mod cost;
11pub use cost::*;
12
13mod outcome;
14pub use outcome::*;
15
16/// The Solver trait defines the interface for market-clearing solvers.
17///
18/// A Solver takes market participant submissions (bids/offers) and computes
19/// the optimal trades and market-clearing prices that maximize total welfare.
20///
21/// Implementations may use different optimization algorithms with varying
22/// performance and precision characteristics.
23pub trait Solver {
24    /// The configuration type for this solver
25    type Settings;
26
27    /// Create a new instance with the provided settings
28    fn new(settings: Self::Settings) -> Self;
29
30    /// Solve the market clearing problem for the given auction submissions
31    ///
32    /// # Parameters
33    /// * `auction` - A slice of Submission objects representing all bids and offers
34    ///
35    /// # Returns
36    /// * `AuctionOutcome` - Contains the clearing prices and trades for each product and authorization
37    fn solve<
38        AuthId: Eq + std::hash::Hash + Clone + Ord,
39        ProductId: Eq + std::hash::Hash + Clone + Ord,
40    >(
41        &self,
42        auction: &[Submission<AuthId, ProductId>],
43        // TODO: warm-starts with the prices
44    ) -> AuctionOutcome<AuthId, ProductId>;
45}