GenXProject / GenX.jl

GenX: a configurable power system capacity expansion model for studying low-carbon energy futures. More details at : https://genx.mit.edu
https://genxproject.github.io/GenX.jl/
GNU General Public License v2.0
270 stars 114 forks source link

Add objective scale to improve numeric efficiency #651

Closed Betristor closed 6 months ago

Betristor commented 6 months ago

In the energy system models that are constructed from GenX, sometimes we shall encounter the problem in numerics in the objective range. To solve this problem easily, a ObjScale could be multiplied when the objective is set like @objective(m, Min, ObjScale*eObj). By doing this, we do not need to reconstruct the model by reformulating the units of parameters and data.

Betristor commented 6 months ago

Taking "SmallNewEngland/OneZone_3VREBin" as example, with ObjScale set to 1, no scaling is applied, the objective range is [1e-04, 5e+02]. If we set the ObjScale to 10, then the objective range shall be scaled to [1e-3, 5e+03] without altering any expressions inside the model, which could still also improve numeric illness if the model contains large objective terms.

ObjScale = 1

IPX model has 32666 rows, 16038 columns and 129140 nonzeros
Input
    Number of variables:                                16038
    Number of free variables:                           0
    Number of constraints:                              32666
    Number of equality constraints:                     4046
    Number of matrix entries:                           129140
    Matrix range:                                       [1e-02, 1e+01]
    RHS range:                                          [8e+00, 2e+03]
    Objective range:                                    [1e-04, 5e+02]
    Bounds range:                                       [8e+00, 9e+02]

ObjScale = 10

IPX model has 32666 rows, 16038 columns and 129140 nonzeros
Input
    Number of variables:                                16038
    Number of free variables:                           0
    Number of constraints:                              32666
    Number of equality constraints:                     4046
    Number of matrix entries:                           129140
    Matrix range:                                       [1e-02, 1e+01]
    RHS range:                                          [8e+00, 2e+03]
    Objective range:                                    [1e-03, 5e+03]
    Bounds range:                                       [8e+00, 9e+02]
sambuddhac commented 6 months ago

Dear @Betristor thanks for raising the issue and the PR to fix. We are in the last legs of releasing GenX v0.4, in which we have tried to fix several similar bugs. I will request you to check this once v0.4 is out to see if the bug still persists, and if it does, we will request you to submit an updated PR to fix it. We expect this new version of GenX to be released (or at least, prereleased this week itself)

sambuddhac commented 6 months ago

Could you please update this issue with your new runs on GenX prerelease v0.4.0-rc?

JesseJenkins commented 6 months ago

@Betristor @sambuddhac is this a bug? A new feature request? Or are you referring to a Gurobi setting?

We have implemented ParameterScale to rescale parameter coefficient range. Are you suggesting we also do so for the objective function?

Betristor commented 6 months ago

@JesseJenkins This is a feature request and I implemented it in PR #667.

sambuddhac commented 6 months ago

I have reviewed the associated PR and commented with this: Can you please mention a concrete example in which the ObjScale is something other than 1? I am failing to understand where exactly the current code-base is having problem? We already have a ParameterScale as @JesseJenkins mentioned in his response to the associated issue. In this PR you have kept the scaling factor to 1 and yet you mentioned in the description that the objective needs to be scaled. So, I am unable to understand. Have you tried using the ParameterScale that's already there in GenX?