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

ExportModelAsMpsFormat creates an unreadable char pointer in Python #4349

Open
giacomoguiduzzi opened this issue Aug 17, 2024 · 2 comments
Open
Assignees
Labels
Help Needed Modeling/Usage problem Lang: Python Python wrapper issue Solver: Linear Solver Related to all Linear Solver (GLOP, BOP, CBC etc...)
Milestone

Comments

@giacomoguiduzzi
Copy link

What version of OR-Tools and what language are you using?
Version: main (9.10.4067 from the venv).
Language: Python

Which solver are you using (e.g. CP-SAT, Routing Solver, GLOP, BOP, Gurobi)
SCIP

What operating system (Linux, Windows, ...) and version?
Ubuntu 22.04 on kernel 5.18

What did you do?
Steps to reproduce the behavior:

  1. Create a solver and add variables and constraints to it
  2. Call the solver.ExportModelAsMpsFormat() function and pass its output to an opened file in write mode
  3. Get error from the interpreter as the output is not a string, but a char * SwigPyObject at address 0xnumbers.

I feel like opening the file as 'wb' instead of 'w' wouldn't solve the issue as I'd save the pointer object, not the pointed string. Can you confirm?

What did you expect to see
The program successfully saving the model to disk.

What did you see instead?
A ValueError exception.

Make sure you include information that can help us debug (full error message, model Proto).
I'm not sure what kind of information could be of use. The model is pretty big and it would be difficult to send here.

Anything else we should know about your project / environment
The ExportModelasLpFormat function works correctly returning a string. I am using Python3.9.19 in a venv.
Let me know if there is anything else that could be useful to know, or if I'm missing something.

Thanks in advance.

Best Regards,
Giacomo Guiduzzi

@lperron
Copy link
Collaborator

lperron commented Aug 18, 2024

How large is the model ?

@giacomoguiduzzi
Copy link
Author

giacomoguiduzzi commented Aug 18, 2024 via email

@Mizux Mizux added Help Needed Modeling/Usage problem Lang: Python Python wrapper issue Solver: Linear Solver Related to all Linear Solver (GLOP, BOP, CBC etc...) labels Aug 20, 2024
@Mizux Mizux added this to the v10.0 milestone Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help Needed Modeling/Usage problem Lang: Python Python wrapper issue Solver: Linear Solver Related to all Linear Solver (GLOP, BOP, CBC etc...)
Projects
None yet
Development

No branches or pull requests

3 participants