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

Fixing the branching tree file #434

Merged
merged 4 commits into from
Jan 20, 2021
Merged

Fixing the branching tree file #434

merged 4 commits into from
Jan 20, 2021

Conversation

artalvpes
Copy link
Collaborator

See the attached file as an example of the generated branching tree.
cvrp2.pdf

@codecov
Copy link

codecov bot commented Jan 16, 2021

Codecov Report

Merging #434 (3962259) into master (3ff9f41) will decrease coverage by 0.04%.
The diff coverage is 93.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #434      +/-   ##
==========================================
- Coverage   80.12%   80.07%   -0.05%     
==========================================
  Files          52       52              
  Lines        4206     4206              
==========================================
- Hits         3370     3368       -2     
- Misses        836      838       +2     
Impacted Files Coverage Δ
src/Algorithm/branching/branchingalgo.jl 90.75% <ø> (-1.44%) ⬇️
src/Algorithm/treesearch.jl 89.54% <93.33%> (+1.34%) ⬆️
src/Algorithm/branching/branchinggroup.jl 86.51% <0.00%> (-2.25%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3ff9f41...3962259. Read the comment docs.

@@ -206,13 +206,20 @@ function print_node_in_branching_tree_file(algo::TreeSearchAlgorithm, data::Tree
if algo.branchingtreefile !== nothing
pb = getvalue(get_ip_primal_bound(getoptstate(data)))
db = getvalue(get_ip_dual_bound(getoptstate(node)))
write(algo.branchingtreefile, read(algo.branchingtreefile, String)[1:end-1])
Copy link
Contributor

@guimarqu guimarqu Jan 18, 2021

Choose a reason for hiding this comment

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

Do you want to remove the last line from the file? Any better way to do this ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No. Only the last character (a closing brace). I pushed a change to use chop() instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to handle the closing brace in another way than copying (almost) the whole file ?

… branching tree file is removed before updating it
@guimarqu
Copy link
Contributor

Alternative ?

io = open("file", "r+")
seekend(io)
truncate(io, position(io)-1)  # assert that position(io) >= 1,   remove last character (last byte actually)
write!(io, "something")
close(io)

cf https://docs.julialang.org/en/v1/base/io-network/

@guimarqu
Copy link
Contributor

Alternative ?

io = open("file", "r+")
seekend(io)
truncate(io, position(io)-1)  # assert that position(io) >= 1,   remove last character (last byte actually)
write!(io, "something")
close(io)

cf https://docs.julialang.org/en/v1/base/io-network/

Even better, you don't need to truncate, you just seek for position end - 1 and you start writing there :

seekend(io)
n = position(io)
seek(io, n-1)
write(io, "something")

@guimarqu guimarqu enabled auto-merge (squash) January 20, 2021 20:51
@guimarqu guimarqu disabled auto-merge January 20, 2021 22:13
@guimarqu guimarqu merged commit 9772423 into master Jan 20, 2021
@guimarqu guimarqu deleted the fix_branchingtreefile branch January 20, 2021 22:15
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

Successfully merging this pull request may close these issues.

2 participants