Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: "cannot reshape array of size" after optimization is finished #376

Open
tburandt opened this issue Nov 13, 2024 · 2 comments
Open

Bug: "cannot reshape array of size" after optimization is finished #376

tburandt opened this issue Nov 13, 2024 · 2 comments

Comments

@tburandt
Copy link
Contributor

tburandt commented Nov 13, 2024

Hi all,

sometimes I get randomly these errors when calling model.solve:

2024-11-13 15:05:34 [INFO]  Optimization successful: 
Status: ok
Termination condition: optimal
Solution: 3017580 primals, 254750 duals
Objective: 3.52e+08
Solver model: available
Solver message: optimal
 in constants.info:239
2024-11-13 15:05:34 [ERROR] Attempt 1 failed with error: cannot reshape array of size 65160 into shape (1086,30) in model_builder.solve:276

rebuilding the model (aka initializing a new model class and re-adding constraints variables, etc without andy data changes) usually solves this problem. However, I run 24h simulations for up to 5-6 years in total and every like 20 simulations, I get this error. Also, its not traceable and not really reproducible. It really occurs randomly and happens with cplex and highs

@FabianHofmann
Copy link
Collaborator

Hey @tburandt, this is quite weird. linopy does not have a model_builder.solve, so I am wondering whether this occurs in one of the other libraries highspy or cplex.

@tburandt
Copy link
Contributor Author

@FabianHofmann hey, yeah sorry, model_builder.solve is my class and in essence only calls model.solve:

    def solve(self, [...]):
        attempt = 0
        while attempt < self.max_retries:
            try:
                logging.info(
                    f"Attempt {attempt + 1}/{self.max_retries} to solve the model."
                )

                model.solve(**solver_kwargs)
                logging.info("Model solved successfully.")
                return model
            except Exception as e:
                [...]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants