The model is structured in Julia. To re-establish the dynamic between the regulated and free markets, a stochastic market equilibrium is used, which integrates multi-stage stochastic optimization and game theory. For the modeling of the agents, it is considered that each of them seeks to maximize their risk-adjusted expected revenue, using the CVaR metric. To establish the equilibrium, the maximization of Welfare is used, that is, to maximize the sum of the objective functions of all agents, respecting the risk profile of each one, with MOPED being used for modeling the constraints. Furthermore, the developed model is integrated with the OptGen (expansion optimization) and OptFolio (contracting optimization from the agent’s perspective) models, to evaluate how the generator’s perspective differs from the centralized planner’s view regarding the viability of building new generation capacity, and to determine the expansion with the lowest systemic cost.