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

Fix treesearch and storage doc, some warnings left in storage #828

Merged
merged 3 commits into from
Apr 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 30 additions & 30 deletions docs/src/api/branching.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ the children of the current node of the branch-and-bound tree.
Coluna provides the following function for this step:

```@docs
select!
Branching.select!
```

It works as follows.
Expand All @@ -41,39 +41,39 @@ At last, it returns the candidates kept.
### Branching rule

```@docs
AbstractBranchingRule
apply_branching_rule
Branching.AbstractBranchingRule
Branching.apply_branching_rule
```

### Candidate

```@docs
AbstractBranchingCandidate
getdescription
get_lhs
get_local_id
get_children
set_children!
get_parent
generate_children!
Branching.AbstractBranchingCandidate
Branching.getdescription
Branching.get_lhs
Branching.get_local_id
Branching.get_children
Branching.set_children!
Branching.get_parent
Branching.generate_children!
```

### Selection criterion

```@docs
AbstractSelectionCriterion
select_candidates!
Branching.AbstractSelectionCriterion
Branching.select_candidates!
```

### Branching API

```@docs
get_selection_nb_candidates
branching_context_type
new_context
get_int_tol
get_rules
get_selection_criterion
Branching.get_selection_nb_candidates
Branching.branching_context_type
Branching.new_context
Branching.get_int_tol
Branching.get_rules
Branching.get_selection_criterion
```

Method `advanced_select!` is part of the API but presented just below.
Expand All @@ -88,7 +88,7 @@ additional kpis about each branching candidates.
Coluna provides the following function for this step.

```@docs
advanced_select!
Branching.advanced_select!
```

Coluna has two default implementation for this method:
Expand Down Expand Up @@ -118,25 +118,25 @@ restrict the number of retained candidates until only one is left.
### Strong Branching API

```@docs
get_units_to_restore_for_conquer
get_phases
get_score
get_conquer
get_max_nb_candidates
Branching.get_units_to_restore_for_conquer
Branching.get_phases
Branching.get_score
Branching.get_conquer
Branching.get_max_nb_candidates
```

Following methods are part of the API but have default implementation.
We advise to not change them.

```@docs
perform_branching_phase!
eval_children_of_candidate!
eval_child_of_candidate!
Branching.perform_branching_phase!
Branching.eval_children_of_candidate!
Branching.eval_child_of_candidate!
```

#### Score

```@docs
AbstractBranchingScore
compute_score
Branching.AbstractBranchingScore
Branching.compute_score
```
32 changes: 16 additions & 16 deletions docs/src/api/storage.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
# provides two methods to do both actions:

# ```@docs
# create_record
# restore_from_record!
# ColunaBase.create_record
# ColunaBase.restore_from_record!
# ```

# ## Example
Expand Down Expand Up @@ -111,7 +111,7 @@ end
# There is a tutorial about the tree search interface.

# We define the node data structure.
mutable struct Node <: ClA.AbstractNode
mutable struct Node <: Coluna.TreeSearch.AbstractNode
depth::Int
id::Int
branch_description::String
Expand All @@ -123,13 +123,13 @@ mutable struct Node <: ClA.AbstractNode
end
end

ClA.get_root(node::Node) = isnothing(node.parent) ? node : ClA.root(node.parent)
ClA.get_parent(node::Node) = node.parent
Coluna.TreeSearch.get_root(node::Node) = isnothing(node.parent) ? node : Coluna.Treesearch.root(node.parent)
Coluna.TreeSearch.get_parent(node::Node) = node.parent

# We define the search space data structure.
# Note that we keep the storage in the search space because we have access to this
# data structure throughout the whole tree search execution.
mutable struct FullExplSearchSpace <: ClA.AbstractSearchSpace
mutable struct FullExplSearchSpace <: Coluna.TreeSearch.AbstractSearchSpace
nb_nodes_generated::Int
formulation::Formulation
solution::Tuple{Vector{Float64},Float64}
Expand All @@ -141,7 +141,7 @@ mutable struct FullExplSearchSpace <: ClA.AbstractSearchSpace
end

# We implement the method that returns the root node.
function ClA.new_root(space::FullExplSearchSpace, _)
function Coluna.TreeSearch.new_root(space::FullExplSearchSpace, _)
space.nb_nodes_generated += 1
return Node(nothing, 1, "", nothing)
end
Expand Down Expand Up @@ -248,20 +248,20 @@ end;

# We define the method `children` of the tree search API.
# It evaluates the current node and then generates its children.
function ClA.children(space::FullExplSearchSpace, current, _, _)
function Coluna.TreeSearch.children(space::FullExplSearchSpace, current, _, _)
evaluate_current_node(space, current)
return create_children(space, current)
end

# We don't define specific stopping criterion.
ClA.stop(::FullExplSearchSpace, _) = false
Coluna.TreeSearch.stop(::FullExplSearchSpace, _) = false

# We return the best solution and the record at each node to make sure the example worked.
ClA.tree_search_output(space::FullExplSearchSpace, _) = space.record_ids_per_node, space.solution
Coluna.TreeSearch.tree_search_output(space::FullExplSearchSpace, _) = space.record_ids_per_node, space.solution

# We run the example.
search_space = FullExplSearchSpace(formulation)
ClA.tree_search(ClA.DepthFirstStrategy(), search_space, nothing, nothing)
Coluna.TreeSearch.tree_search(Coluna.TreeSearch.DepthFirstStrategy(), search_space, nothing, nothing)


# ## API
Expand All @@ -282,9 +282,9 @@ ClA.tree_search(ClA.DepthFirstStrategy(), search_space, nothing, nothing)
# Entities can be in the storage unit, the model, or in both of them.

# ```@docs
# record_type
# storage_unit_type
# new_storage_unit
# new_record
# restore_from_record!
# ColunaBase.record_type
# ColunaBase.storage_unit_type
# ColunaBase.new_storage_unit
# ColunaBase.new_record
# ColunaBase.restore_from_record!
# ```
Loading