Fix Markov simulation chart display issue
- Fix circular import issue by moving simulation_manager to app/__init__.py - Enhance get_wealth_evolution to include inequality metrics data - Add get_inequality_evolution method for complete chart data - Update API to return top10_shares and capital_shares in evolution data - Modify onSimulationComplete to fetch and populate charts with complete data - Fix simulation threading to properly mark completion state - Add test script to verify chart data generation The charts now properly display simulation results by fetching complete evolution data when simulation completes, resolving the empty diagrams issue.
This commit is contained in:
@@ -262,6 +262,23 @@ class EconomicSimulation:
|
||||
|
||||
return iterations, total_wealth, gini_coefficients
|
||||
|
||||
def get_inequality_evolution(self) -> Tuple[List[int], List[float], List[float], List[float]]:
|
||||
"""
|
||||
Get inequality evolution data for plotting.
|
||||
|
||||
Returns:
|
||||
Tuple of (iterations, gini_over_time, top10_share_over_time, capital_share_over_time)
|
||||
"""
|
||||
if not self.snapshots:
|
||||
return [], [], [], []
|
||||
|
||||
iterations = [s.iteration for s in self.snapshots]
|
||||
gini_coefficients = [s.gini_coefficient for s in self.snapshots]
|
||||
top10_shares = [s.wealth_concentration_top10 for s in self.snapshots]
|
||||
capital_shares = [s.capital_share for s in self.snapshots]
|
||||
|
||||
return iterations, gini_coefficients, top10_shares, capital_shares
|
||||
|
||||
def get_agent_wealth_distribution(self) -> Dict[str, List[float]]:
|
||||
"""
|
||||
Get current wealth distribution across all agents.
|
||||
|
Reference in New Issue
Block a user