make pyomo problem definition more efficient

30 Views Asked by At

I am defining a problem in pyomo a MINLP one. Let's say I have 1000 decision variables and in my problem, some of the decision variables can interact with each other (cross effects). I am defining the interaction thanks to a matrix then in Pyomo I am using pe. Param and giving it a dictionnary for this.

The assignation of this param is slow and the assignation of the objective function is also slow. Below a preview of this dictionary used a param: enter image description here

How can I make the assignation faster? It's worth mentioning that my matrix is sparse.

Below how the matrix is used :

model.obj = pe.Objective(
        expr=sum(
            (
                self.model.decision_var[i]
                * (
                    pe.exp(
                        sum(
                            self.model.the_matrix[i, j]
                            * pe.log(self.model.decision_var[j])
                            for j in self.model.decision_id
                        )
                        + self.model.intercept[i]
                    )
                )
            )
            for i in self.model.decision_id
        ),
        sense=pe.maximize,
    )
0

There are 0 best solutions below