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