Class SupplyDemandModel

java.lang.Object
org.episteme.social.economics.models.SupplyDemandModel

public final class SupplyDemandModel extends Object
Analytical tool for modeling supply and demand curves and calculating competitive equilibrium. It provides mathematical utilities for market efficiency analysis, including consumer/producer surplus and deadweight loss.
Since:
1.0
Version:
2.0
Author:
Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
  • Method Details

    • findEquilibriumPrice

      public static Real findEquilibriumPrice(RealFunction supply, RealFunction demand, Real priceLow, Real priceHigh, Real tolerance)
      Resolves the market equilibrium price where the quantity supplied exactly equals the quantity demanded.
      Parameters:
      supply - the supply function S(p)
      demand - the demand function D(p)
      priceLow - lower bound for numerical search
      priceHigh - upper bound for numerical search
      tolerance - precision limit for the solver
      Returns:
      the calculated equilibrium price
    • consumerSurplus

      public static Real consumerSurplus(RealFunction demand, Real equilibriumPrice, Real equilibriumQuantity)
      Calculates the Consumer Surplus (CS), representing the cumulative difference between what consumers are willing to pay and the market price. Formula: integral[0 to Q*] (D(q) - P*) dq
      Parameters:
      demand - the demand function D(q) mapping quantity to price
      equilibriumPrice - (P*) the market clearing price
      equilibriumQuantity - (Q*) the market clearing quantity
      Returns:
      cumulative consumer surplus value
    • producerSurplus

      public static Real producerSurplus(RealFunction supply, Real equilibriumPrice, Real equilibriumQuantity)
      Calculates the Producer Surplus (PS), representing the cumulative difference between the market price and the price producers are willing to accept. Formula: integral[0 to Q*] (P* - S(q)) dq
      Parameters:
      supply - the supply function S(q) mapping quantity to price
      equilibriumPrice - (P*) the market clearing price
      equilibriumQuantity - (Q*) the market clearing quantity
      Returns:
      cumulative producer surplus value
    • totalWelfare

      public static Real totalWelfare(RealFunction supply, RealFunction demand, Real equilibriumPrice, Real equilibriumQuantity)
      Calculates the Total Social Welfare as the sum of consumer and producer surpluses.
      Parameters:
      supply - supply function S(q)
      demand - demand function D(q)
      equilibriumPrice - market price
      equilibriumQuantity - market quantity
      Returns:
      total economic welfare
    • deadweightLoss

      public static Real deadweightLoss(RealFunction supply, RealFunction demand, Real equilibriumQuantity, Real actualQuantity)
      Calculates the Deadweight Loss (DWL) resulting from market inefficiencies or external interventions (e.g., price caps).
      Parameters:
      supply - supply function S(q)
      demand - demand function D(q)
      equilibriumQuantity - (Q*) the efficient quantity
      actualQuantity - the actual traded quantity
      Returns:
      value of lost economic efficiency (DWL)
    • priceElasticity

      public static Real priceElasticity(RealFunction demand, Real price, Real deltaP)
      Estimates the Price Elasticity of Demand (PED) at a specific price point. Formula: E = (dQ/dP) * (P/Q)
      Parameters:
      demand - demand function D(p)
      price - target price point
      deltaP - increment for numerical derivative approximation
      Returns:
      point elasticity value