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

correcting max-flow problem in MILP tutorial #38557

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

anshu129
Copy link

@anshu129 anshu129 commented Aug 23, 2024

tdf #35497 incorrect max-flow problem formulation in MILP tutorial

I have made changes in two files , just completed the objective function as described in the comments.
p.set_objective(p.sum(f[s,u] for u in g.neighbors_out(s)) - p.sum(f[v,s] for v in g.neighbors_in(s)))

#35497 (comment)

  • The title is concise and informative.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation and checked the documentation preview.

@dcoudert
Copy link
Contributor

Please rebase this branch on last beta. I will then review it.

@anshu129
Copy link
Author

anshu129 commented Sep 22, 2024

@dcoudert I have tried rebasing it . if there is any problem. plz let me know.

Copy link
Contributor

@dcoudert dcoudert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@vbraun
Copy link
Member

vbraun commented Sep 26, 2024

I'm getting

sage -t --long --warn-long 55.4 --random-seed=123 src/sage/tests/books/computational-mathematics-with-sagemath/lp_doctest.py
**********************************************************************
File "src/sage/tests/books/computational-mathematics-with-sagemath/lp_doctest.py", line 194, in sage.tests.books.computational-mathematics-with-sagemath.lp_doctest
Failed example:
    p.solve()
Exception raised:
    Traceback (most recent call last):
      File "/home/release/Sage/src/sage/doctest/forker.py", line 714, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/home/release/Sage/src/sage/doctest/forker.py", line 1144, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.tests.books.computational-mathematics-with-sagemath.lp_doctest[58]>", line 1, in <module>
        p.solve()
      File "sage/numerical/mip.pyx", line 2638, in sage.numerical.mip.MixedIntegerLinearProgram.solve
        self._backend.solve()
      File "sage/numerical/backends/glpk_backend.pyx", line 1142, in sage.numerical.backends.glpk_backend.GLPKBackend.solve
        raise MIPSolverException("GLPK: "+solve_status_msg.get(solve_status, "unknown error during call to GLPK : "+str(solve_status)))
    sage.numerical.mip.MIPSolverException: GLPK: The LP (relaxation) problem has no dual feasible solution
**********************************************************************

@anshu129
Copy link
Author

anshu129 commented Oct 5, 2024

@vbraun @dcoudert @mkoeppe any suggestions, how I can correct the error and close the PR.

@dcoudert
Copy link
Contributor

dcoudert commented Oct 5, 2024

try to change

 Sage example in ./lp.tex, line 681::
 
-  sage: for e in g.edges(sort=True, labels = False): p.add_constraint( f[e] <= 1 )
+  sage: for e in g.edges(labels=False): p.add_constraint(f[e], min=0, max=1)

Copy link

Documentation preview for this PR (built with commit e7326d5; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

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

Successfully merging this pull request may close these issues.

4 participants