Open maxale opened 1 year ago
It's a common simplifying assumption that the distinguished source node has no incoming arcs; in this situation, the simpler formulation can be used. To fix it, either the proposed change is fine (best if accompanied by an example that includes a circulation through s); or the assumption should be stated.
In the given graph example graphs.ChvatalGraph().minimum_outdegree_orientation()
the assumption that source s = 0
has no incoming edges does not hold.
Thanks for checking. I'll be happy to review a PR
Please assign this to me @mkoeppe
Hi @mkoeppe , I think my code can address to the issue from sage.numerical.mip import MixedIntegerLinearProgram
g = graphs.ChvatalGraph() g = g.minimum_outdegree_orientation()
p = MixedIntegerLinearProgram() f = p.new_variable(real=True, nonnegative=True) s, t = 0, 2
for v in g: p.add_constraint( p.sum(f[v, u] for u in g.neighbors_out(v))
for e in g.edges(labels=False): p.add_constraint(f[e] <= 1)
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)))
p.solve() # rel tol 2e-11
Can I get assigned to this problem?
@anshu129 - why do you ask for assignment? Just create a pull request and give a link here.
@maxale sorry, I didn't know at that time how to create a pr, I thought maybe getting assigned is related to pr . I will try to solve the issue and create a PR. Thank you
@maxale, could you please review the PR and let me know if any changes are required? thank you
@anshu129, you corrected the code, but forgot about the problem formulation in LaTeX just before that (line 389 in linear_programming.rst
Also, please run the updated code and make sure the present execution results are consistent with the update.
@maxale I have tried to changing the latex function in linear_programming.rst , I don't have much idea about latex, can you plz tell me if any new constraint should be added .
@anshu129: Change \text{Max: } & \sum_{sv \in G} f_{sv}\\
to \text{Max: } & \sum_{su \in G} f_{su} - \sum_{vs\in G} f_{vs}\\
@maxale : I changed the function \text{Max: } & \sum{su \in G} f{su} - \sum{sv\in G} f{sv}\ to
\text{Max: } & \sum{su \in G} f{su} - \sum{vs\in G} f{vs}\
in my 3rd commit, can you check it out , and tell me any other change
PR looks good to me now.
@maxale can you review the PR and close it .
@anshu129 I do not have reviewing priviledge.
@mkoeppe can you review the PR and close it .
Is there an existing issue for this?
Did you read the documentation and troubleshoot guide?
Environment
Steps To Reproduce
In the tutorial "Linear Programming (Mixed Integer)" in the section "Flows" at https://doc.sagemath.org/html/en/thematic_tutorials/linear_programming.html#flows the objective function is incorrect.
Expected Behavior
The objective function should be stated as $$\textrm{Max}:\quad\sum{su\in G} f{su} - \sum{vs\in G} f{vs}$$ with the corresponding code:
Actual Behavior
The objective function is currently stated as $$\textrm{Max}:\quad\sum{sv\in G} f{sv}$$ with the corresponding code:
Sometimes it produces an incorrect solution.
Additional Information
As a reference, e.g. see this lecture notes: https://www.cs.cmu.edu/~odonnell/toolkit13/lecture14.pdf