Skip to content

Commit

Permalink
treesearch -> explore (#192)
Browse files Browse the repository at this point in the history
  • Loading branch information
guimarqu authored Sep 30, 2019
1 parent 2cdc97d commit 480e4ff
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/Coluna.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ include("strategies/conquer/simplebenders.jl")
# Here include divide strategies
include("strategies/divide/simplebranching.jl")

# Here include tree search strategies
include("strategies/treesearch/simplestrategies.jl")
# Here include explore strategies
include("strategies/explore/simplestrategies.jl")

# Wrapper functions
include("MOIwrapper.jl")
Expand Down
16 changes: 8 additions & 8 deletions src/algorithms/reformulationsolver.jl
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
mutable struct SearchTree
nodes::DS.PriorityQueue{Node, Float64}
search_strategy::AbstractTreeSearchStrategy
explore_strategy::AbstractExploreStrategy
fully_explored::Bool
end

SearchTree(search_strategy::AbstractTreeSearchStrategy) = SearchTree(
DS.PriorityQueue{Node, Float64}(Base.Order.Forward), search_strategy,
SearchTree(explore_strategy::AbstractExploreStrategy) = SearchTree(
DS.PriorityQueue{Node, Float64}(Base.Order.Forward), explore_strategy,
true
)

getnodes(t::SearchTree) = t.nodes
Base.isempty(t::SearchTree) = isempty(t.nodes)

push!(t::SearchTree, node::Node) = DS.enqueue!(t.nodes, node, apply!(t.search_strategy, node))
push!(t::SearchTree, node::Node) = DS.enqueue!(t.nodes, node, apply!(t.explore_strategy, node))
popnode!(t::SearchTree) = DS.dequeue!(t.nodes)
nb_open_nodes(t::SearchTree) = length(t.nodes)
was_fully_explored(t::SearchTree) = t.fully_explored
Expand All @@ -31,10 +31,10 @@ mutable struct ReformulationSolver <: AbstractAlgorithm
result::OptimizationResult
end

function ReformulationSolver(search_strategy::AbstractTreeSearchStrategy,
function ReformulationSolver(explore_strategy::AbstractExploreStrategy,
ObjSense::Type{<:AbstractObjSense})
return ReformulationSolver(
SearchTree(search_strategy), SearchTree(DepthFirst()),
SearchTree(explore_strategy), SearchTree(DepthFirst()),
true, 1, 0, OptimizationResult{ObjSense}()
)
end
Expand Down Expand Up @@ -84,10 +84,10 @@ function run_reform_solver!(reform::Reformulation, strategy::GlobalStrategy)
# Get all strategies
conquer_strategy = strategy.conquer
divide_strategy = strategy.divide
tree_search_strategy = strategy.tree_search
explore_strategy = strategy.explore

reform_solver = ReformulationSolver(
tree_search_strategy, reform.master.obj_sense
explore_strategy, reform.master.obj_sense
)
push!(reform_solver, RootNode(reform.master.obj_sense))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Depth-first strategy
struct DepthFirst <: AbstractTreeSearchStrategy end
struct DepthFirst <: AbstractExploreStrategy end
apply!(algo::DepthFirst, n::AbstractNode) = (-n.depth)

# Best dual bound strategy
struct BestDualBound <: AbstractTreeSearchStrategy end
struct BestDualBound <: AbstractExploreStrategy end
apply!(algo::BestDualBound, n::AbstractNode) = get_ip_dual_bound(getincumbents(n))
13 changes: 7 additions & 6 deletions src/strategies/strategy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ branch-and-bound node.
abstract type AbstractDivideStrategy <: AbstractStrategy end

"""
AbstractTreeSearchStrategy
AbstractExploreStrategy
A TreeSearchStrategy defines how the branch-and-bound tree shall be
searhed. To define a concrete `AbstractTreeSearchStrategy` one must define the function
`apply!(strategy::Type{<:AbstractTreeSearchStrategy}, n::Node)`.
An ExploreStrategy defines how the branch-and-bound tree shall be
searched. To define a concrete `AbstractExploreStrategy`, one must define
the function
`apply!(strategy::Type{<:AbstractExploreStrategy}, n::Node)`.
"""
abstract type AbstractTreeSearchStrategy <: AbstractStrategy end
abstract type AbstractExploreStrategy <: AbstractStrategy end

"""
apply!(strategy::AbstractStrategy, args...)
Expand Down Expand Up @@ -58,5 +59,5 @@ in solving a `Reformulation`. Each `Reformulation` keeps an objecto of type Glob
struct GlobalStrategy <: AbstractStrategy
conquer::AbstractConquerStrategy
divide::AbstractDivideStrategy
tree_search::AbstractTreeSearchStrategy
explore::AbstractExploreStrategy
end

0 comments on commit 480e4ff

Please sign in to comment.