0

I want a binary variable, $inv_year$, to indicate the investment year, i.e., the year where the investment variable, $I$, turns greater than zero for the first time. Both variables ($inv_year$ and $I$) have two indices, time $t$ and project $i$.

In theory, the variable $inv_year[i,t]$ should equal to 1 for the minimum of time $t$ when I[i,t] is greater than 0. It should turn 1 once for each project $i$ to indicate the investment year for that project.

I am using the Big M method in Pyomo, but right now the binary variable, $inv_\year$, turns 1 always when the variable $I$ turns greater than zero. Therefore, the binary investment year variable equals 1 multiple times, rather than only once for each project.

Is there a ways to adjust the Big M method to work like this or do I have to use a different method for this purpose?

Right now, my solution looks as follows:

#First constraint, Big-M method for binary variable inv_year 
def bigM_constraint1(model, i, t):
    lhs_1 = model.inv_year[i,t]
    rhs_1 = model.I[i,t]
    return lhs_1<=rhs_1

#add the rule to the model as a constraint
model.BigM_Constraint1 = Constraint(model.project_type, model.time, rule=bigM_constraint1)

#Second constraint, Big-M method for binary variable inv_year 
def bigM_constraint2(model, i, t):
    lhs_2 = model.I[i,t]
    rhs_2 = model.M[i] * model.inv_year[i,t]
    return lhs_2<=rhs_2

#add the rule to the model as a constraint
model.BigM_Constraint2 = Constraint(model.project_type, model.time, rule=bigM_constraint2)
3
  • It's certainly possible; however, the difficulty of doing this varies based on a lot of things including whether the year selectors are optimisation objectives, and whether the optimisation variables are binary or continuous. Commented May 6, 2024 at 12:03
  • @Reinderien thanks for your answer! The optimisation or decision variables are the investment variables, I[i,t], which determine the investment amount in a given year into a given project, and they are continuous variables. The binary investment year variables are not the decision variables. They depend on the investment variables as specified by the big M constraints. Commented May 6, 2024 at 13:32
  • Please edit your question to describe these details and include the relevant code. Commented May 6, 2024 at 13:44

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.