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

can't find LP file #632

Closed
HorizonLiang opened this issue Dec 8, 2022 · 7 comments
Closed

can't find LP file #632

HorizonLiang opened this issue Dec 8, 2022 · 7 comments

Comments

@HorizonLiang
Copy link

from pyscipopt import Model
model = Model("Example")

x = model.addVar("x")
y = model.addVar("y", vtype="INTEGER")
model.setObjective(x + y)
model.addCons(2*x - y*y >= 0)
model.optimize()

model.writeLP("./model.lp")

I can't find the LP file, while runing the code showing above.

@Joao-Dionisio
Copy link
Collaborator

Thank you for opening the issue! Apparently there's something wrong with writeLP(), since the code silently exits while trying to run it. So it isn't actually writing the LP, that's why you can't find it. Alternatively, you have writeProblem(), but I don't know if it does what you want...

@fserra
Copy link
Collaborator

fserra commented Dec 8, 2022

yeah the issue is that writeLP writes the current LP, which mean, the current LP relaxation. If you look at the SCIP documentation, such a function can only be called in the solving stage (which is when an LP relaxation might exist). You need to use writeProblem as @Joao-Dionisio says.

@Joao-Dionisio
Copy link
Collaborator

Joao-Dionisio commented Dec 8, 2022

Thanks, @fserra! There are quite a bit of issues related (even if indirectly) to PySCIPOpt's error handling, as referenced in Issue #610. I will try to take a look at it in the future.

@fserra
Copy link
Collaborator

fserra commented Dec 8, 2022

yes, this is a bit annoying... I guess that ideally one would develop using the underlying scip in debug mode (then a lot more errors would pop up), but that might be too much to ask. An alternative is to start duplicating the checks that already exist in scip, e.g., add something like

        if not self.getStage() == SCIP_STAGE_SOLVING:
            raise Warning("method can only be called in solving stage")

I don't know what is worse

@HorizonLiang
Copy link
Author

  model.writeProblem("model.cip")
  File "src/pyscipopt/scip.pyx", line 1408, in pyscipopt.scip.Model.writeProblem
  File "src/pyscipopt/scip.pyx", line 246, in pyscipopt.scip.PY_SCIP_CALL
OSError: SCIP: cannot create file!

thanks for your reply, however, it still show a error after using the function 'writeProblem'.
the error log shows above.

@Joao-Dionisio
Copy link
Collaborator

This is strange @HorizonLiang... I can run the code without issue:

image

Can it be a problem of having an outdated SCIP? Do you know which version you are using?

@Joao-Dionisio
Copy link
Collaborator

I am closing the issue to clear the Issues page, but feel free to reopen it if you still have problems!

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

3 participants