Hi Wang Chen,
I'm glad you're finding Switch useful. Switch is an optimization model, so the decision making is somewhat automatic and not explicitly visible. In this kind of model, you tell it the formula for calculating costs and any rules that need to be
satisfied, and then the solver automatically makes decisions that will minimize the total costs while following those rules.
In Switch, the generators.dispatch module shows the rules that have to be followed, e.g., you can only dispatch generators if they have been built (if using the no_commit module) or have been committed (if using the commit module). It also adds
some cost terms to the overall cost function for the model (probably just variable O&M).
The fuel_costs module or fuel_markets modules also define variables for the amount of fuel that is burned by each plant, and force that to be consistent with the amount of power that is produced. They also calculate the cost of that fuel and
add it to the overall model cost.
Once this is done, the solver automatically chooses values for all variables (both the dispatch variables and the construction variables) that will minimize costs while meeting all the rules (constraints).
Another way to think about this type of model: all the Params (parameters) and Sets are data provided by the user or that are calculated directly from that data. Vars (decision variables) are numbers that will be chosen by the solver, in order
to minimize the Objective function (total cost) while satisfying all the Constraints in the model. The Expressions in the model are generally just calculations based on the decision variables, which can be labeled and reused as needed.
So you won't find any code saying exactly how the decision variables will be set; instead you have to assume the solver will set them to their optimal values, among all the feasible solutions.
I hope this helps -- let me know if you have any more questions.
Matthias