mirror of
https://github.com/velocitatem/PHANTOM.git
synced 2026-05-31 08:33:36 +00:00
chore: better wrapping amd more performant
This commit is contained in:
@@ -8,7 +8,8 @@ def generate_demand(prices, distribution_method = np.random.normal, distribution
|
||||
product_valuations = distribution_method(*distribution_params, size=len(prices))
|
||||
# assumption 2: demand decreases as price increases, following a simple linear model
|
||||
demand = np.maximum(0, product_valuations - prices) # demand cannot be negative
|
||||
demand = demand / np.sum(demand) * 100 # normalize to total demand of 1000 units so demand output is within [0, 100]
|
||||
total = np.sum(demand)
|
||||
demand = demand / total * 100 if total > 0 else demand # normalize to percentage, avoid div by zero
|
||||
logger.info(f"Generated demand for prices {prices}: {demand} with valuations from distribution {distribution_params}")
|
||||
return demand
|
||||
|
||||
|
||||
Reference in New Issue
Block a user