Skip to content

store vars in parameters to improve RAM and performance #618

Description

@Redmonkeycloud

To-do

  • V01GapTranspActiv(PB)

  • VmGDPPartGlob

  • p01CostTranspPerMeanConsSize was unassigned, others too?

  • Did the 1st task but it the gains were very small -> from --- main.gms(171391) 6190 Mb to --- main.gms(170922) 6123 Mb

  • Task 2 is more complex

Task description

1. Structural Refactoring: Variable-to-Parameter Conversion

Objective: Reduce the Jacobian matrix size by identifying "Pseudo-Variables."
In large-scale models, many variables are technically "accounting" variables—they calculate totals or intermediate steps but do not provide degrees of freedom to the solver.
Identification Strategy

  • Deterministic Equations: Any variable defined by an equation where all other components are parameters (e.g., Total(i) =e= Fixed_Cost * Quantity(i)).
  • Single-Point Mapping: Variables that exist solely for reporting purposes in the .lst or GDX files.
  • Fixed Bounds: Variables where L = LO = UP across the entire domain.
    Impact
  • RAM Savings: Significant reduction in memory used for the model generation (Matrix building).
  • Speed: Faster "Presolve" phase for the solver as it has fewer columns to evaluate.

2. Temporal Optimization: Storing Historical Solutions

Objective: Handle multi-period or recursive models by "fixing" the past.
When running models over a time horizon (e.g., 2020–2050), keeping every year as an active variable leads to exponential growth in model complexity. This task involves "offloading" solved years into static parameters.
Workflow

  • The Solve Loop: Run the model for the current time step (t).
  • Data Offloading: Store the level values (.l) of the variables into a parameter.
    Results_Param(t, i) = MyVariable.l(t, i);

30/06/26 run:

Image

Metadata

Metadata

Labels

enhancementNew feature or request

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions