From e0facecb0b98ef22cd2ba49d0e2ce1bcfebde3db Mon Sep 17 00:00:00 2001 From: odow Date: Fri, 16 May 2025 14:21:55 +1200 Subject: [PATCH] Remove unneeded module prefixes --- src/LibSCIP.jl | 2 +- src/MOI_wrapper/HeuristicCallback.jl | 16 +++++++------- src/MOI_wrapper/conflict.jl | 10 ++++----- src/MOI_wrapper/constraints.jl | 2 +- src/MOI_wrapper/linear_constraints.jl | 2 +- src/MOI_wrapper/quadratic_constraints.jl | 22 +++++++++---------- src/branching_rule.jl | 6 ++--- src/convenience.jl | 2 +- src/cut_selector.jl | 4 ++-- src/event_handler.jl | 28 ++++++++++++------------ src/heuristic.jl | 2 +- src/scip_data.jl | 2 +- 12 files changed, 49 insertions(+), 49 deletions(-) diff --git a/src/LibSCIP.jl b/src/LibSCIP.jl index 4ae423ae..117da210 100644 --- a/src/LibSCIP.jl +++ b/src/LibSCIP.jl @@ -63969,7 +63969,7 @@ const ARTIFICIALVARNAMEPREFIX = "andresultant_" const SCIPisFinite = isfinite # exports -const PREFIXES = ["SCIP_", "SCIP", "BMS_"] +const PREFIXES = ["SCIP", "BMS_"] for name in names(@__MODULE__; all=true), prefix in PREFIXES if startswith(string(name), prefix) @eval export $name diff --git a/src/MOI_wrapper/HeuristicCallback.jl b/src/MOI_wrapper/HeuristicCallback.jl index 3c33d5fd..26e90990 100644 --- a/src/MOI_wrapper/HeuristicCallback.jl +++ b/src/MOI_wrapper/HeuristicCallback.jl @@ -84,25 +84,25 @@ function MOI.submit( heur_ = o.inner.heuristic_storage[heuristic] sol = create_empty_scipsol(o.inner.scip[], heur_) for idx in eachindex(x) - SCIP.@SCIP_CALL SCIP.SCIPsetSolVal( + @SCIP_CALL SCIPsetSolVal( o.inner.scip[], sol, var(o, x[idx]), values[idx], ) end - stored = Ref{SCIP_Bool}(SCIP.FALSE) + stored = Ref{SCIP_Bool}(FALSE) @SCIP_CALL SCIPtrySolFree( o.inner.scip[], Ref(sol), - SCIP.FALSE, - SCIP.FALSE, - SCIP.TRUE, - SCIP.TRUE, - SCIP.TRUE, + FALSE, + FALSE, + TRUE, + TRUE, + TRUE, stored, ) - if stored[] == SCIP.TRUE + if stored[] == TRUE callback_data.submit_called = true end return diff --git a/src/MOI_wrapper/conflict.jl b/src/MOI_wrapper/conflict.jl index bc1453a7..117ccce4 100644 --- a/src/MOI_wrapper/conflict.jl +++ b/src/MOI_wrapper/conflict.jl @@ -29,8 +29,8 @@ function compute_minimum_unsatisfied_constraints!(o::Optimizer) ) end # free the transformed problem first - if LibSCIP.SCIPgetStage(o) != LibSCIP.SCIP_STAGE_PROBLEM - @SCIP_CALL LibSCIP.SCIPfreeTransform(o) + if SCIPgetStage(o) != SCIP_STAGE_PROBLEM + @SCIP_CALL SCIPfreeTransform(o) end # first transform all variable bound constraints to constraint bounds for (F, S) in MOI.get(o, MOI.ListOfConstraintTypesPresent()) @@ -68,9 +68,9 @@ function compute_minimum_unsatisfied_constraints!(o::Optimizer) end end end - success = Ref{LibSCIP.SCIP_Bool}(SCIP.FALSE) - @SCIP_CALL LibSCIP.SCIPtransformMinUC(o, success) - if success[] != SCIP.TRUE + success = Ref{SCIP_Bool}(FALSE) + @SCIP_CALL SCIPtransformMinUC(o, success) + if success[] != TRUE error( "Failed to compute the minimum unsatisfied constraints system.\nSome constraint types may not support the required transformations", ) diff --git a/src/MOI_wrapper/constraints.jl b/src/MOI_wrapper/constraints.jl index 9cfb0134..c8201c6b 100644 --- a/src/MOI_wrapper/constraints.jl +++ b/src/MOI_wrapper/constraints.jl @@ -120,5 +120,5 @@ function MOI.is_valid(o::Optimizer, c::MOI.ConstraintIndex{F,S}) where {F,S} if !in(ConsRef(c.value), cons_set) return false end - return haskey(o.inner.conss, SCIP.ConsRef(c.value)) + return haskey(o.inner.conss, ConsRef(c.value)) end diff --git a/src/MOI_wrapper/linear_constraints.jl b/src/MOI_wrapper/linear_constraints.jl index 94ac4902..6cf6ea5e 100644 --- a/src/MOI_wrapper/linear_constraints.jl +++ b/src/MOI_wrapper/linear_constraints.jl @@ -31,7 +31,7 @@ function MOI.add_constraint( end function MOI.set( - o::SCIP.Optimizer, + o::Optimizer, ::MOI.ConstraintSet, ci::MOI.ConstraintIndex{<:MOI.ScalarAffineFunction{Float64},S}, set::S, diff --git a/src/MOI_wrapper/quadratic_constraints.jl b/src/MOI_wrapper/quadratic_constraints.jl index ab8c3d82..8b59d49a 100644 --- a/src/MOI_wrapper/quadratic_constraints.jl +++ b/src/MOI_wrapper/quadratic_constraints.jl @@ -60,15 +60,15 @@ function MOI.get( expr_ref = SCIPgetExprNonlinear(c) # This call is required to get quaddata computed in the expression isq = Ref{UInt32}(100) - @SCIP_CALL LibSCIP.SCIPcheckExprQuadratic(o, expr_ref, isq) + @SCIP_CALL SCIPcheckExprQuadratic(o, expr_ref, isq) @assert isq[] == 1 constant_ref = Ref{Cdouble}(-1.0) n_linear_terms_ref = Ref{Cint}(-1) - linear_exprs = Ref{Ptr{Ptr{LibSCIP.SCIP_EXPR}}}() + linear_exprs = Ref{Ptr{Ptr{SCIP_EXPR}}}() lincoefs = Ref{Ptr{Cdouble}}() n_quad_terms_ref = Ref{Cint}(-1) n_bilinear_terms_ref = Ref{Cint}(-1) - LibSCIP.SCIPexprGetQuadraticData( + SCIPexprGetQuadraticData( expr_ref, constant_ref, n_linear_terms_ref, @@ -83,16 +83,16 @@ function MOI.get( unsafe_wrap(Vector{Ptr{Cvoid}}, linear_exprs[], n_linear_terms_ref[]) lin_coeff_vec = unsafe_wrap(Vector{Cdouble}, lincoefs[], n_linear_terms_ref[]) - func = SCIP.MOI.ScalarQuadraticFunction{Float64}([], [], constant_ref[]) + func = MOI.ScalarQuadraticFunction{Float64}([], [], constant_ref[]) for idx in 1:n_linear_terms_ref[] - var_ptr = LibSCIP.SCIPgetVarExprVar(lin_expr_vec[idx]) + var_ptr = SCIPgetVarExprVar(lin_expr_vec[idx]) func += lin_coeff_vec[idx] * MOI.VariableIndex(o.reference[var_ptr].val) end for term_idx in 1:n_quad_terms_ref[] var_expr = Ref{Ptr{Cvoid}}() lin_coef_ref = Ref{Cdouble}() sqr_coef_ref = Ref{Cdouble}() - LibSCIP.SCIPexprGetQuadraticQuadTerm( + SCIPexprGetQuadraticQuadTerm( expr_ref, term_idx - 1, # 0-indexed terms var_expr, @@ -104,7 +104,7 @@ function MOI.get( ) @assert lin_coef_ref[] == 0.0 if sqr_coef_ref[] != 0.0 - var_ptr = LibSCIP.SCIPgetVarExprVar(var_expr[]) + var_ptr = SCIPgetVarExprVar(var_expr[]) var_idx = MOI.VariableIndex(o.reference[var_ptr].val) MOI.Utilities.operate!( +, @@ -118,7 +118,7 @@ function MOI.get( var_expr1 = Ref{Ptr{Cvoid}}() var_expr2 = Ref{Ptr{Cvoid}}() coef_ref = Ref{Cdouble}() - LibSCIP.SCIPexprGetQuadraticBilinTerm( + SCIPexprGetQuadraticBilinTerm( expr_ref, term_idx - 1, var_expr1, @@ -128,9 +128,9 @@ function MOI.get( C_NULL, ) if coef_ref[] != 0.0 - var_ptr1 = LibSCIP.SCIPgetVarExprVar(var_expr1[]) + var_ptr1 = SCIPgetVarExprVar(var_expr1[]) var_idx1 = MOI.VariableIndex(o.reference[var_ptr1].val) - var_ptr2 = LibSCIP.SCIPgetVarExprVar(var_expr2[]) + var_ptr2 = SCIPgetVarExprVar(var_expr2[]) var_idx2 = MOI.VariableIndex(o.reference[var_ptr2].val) MOI.Utilities.operate!( +, @@ -164,7 +164,7 @@ function MOI.get( c = cons(o, ci) expr_ref = SCIPgetExprNonlinear(c) isq = Ref{UInt32}(100) - @SCIP_CALL LibSCIP.SCIPcheckExprQuadratic(o, expr_ref, isq) + @SCIP_CALL SCIPcheckExprQuadratic(o, expr_ref, isq) @assert isq[] == 1 sol = SCIPgetBestSol(o) @SCIP_CALL SCIPevalExpr(o, expr_ref, sol, Clonglong(0)) diff --git a/src/branching_rule.jl b/src/branching_rule.jl index fab2274c..8a1bc88a 100644 --- a/src/branching_rule.jl +++ b/src/branching_rule.jl @@ -42,7 +42,7 @@ Perform branching with the current `branching_rule`. `allow_additional_constraints` is a Boolean indicating if the branching rule is allowed to add constraints to the current node in order to cut off the current solution instead of creating a branching. -That method must return a tuple (return_code::LibSCIP.SCIP_RETCODE, result::SCIP.LibSCIP.SCIP_RESULT). +That method must return a tuple (return_code::SCIP_RETCODE, result::SCIP_RESULT). If no branching was performed, use `SCIP_DIDNOTRUN` as a result to pass on to the following branching rule. `type` is the `BranchingType` to branch on, i.e. on LP solution, pseudo-solution or external candidate. @@ -53,7 +53,7 @@ function branch( allow_additional_constraints, type::BranchingType, ) - return (LibSCIP.SCIP_OKAY, LibSCIP.SCIP_DIDNOTRUN) + return (SCIP_OKAY, SCIP_DIDNOTRUN) end """ @@ -104,7 +104,7 @@ function get_branching_candidates(scip) end function branch_on_candidate!(scip, var) - @SCIP_CALL LibSCIP.SCIPbranchVar(scip, var, C_NULL, C_NULL, C_NULL) + @SCIP_CALL SCIPbranchVar(scip, var, C_NULL, C_NULL, C_NULL) return nothing end diff --git a/src/convenience.jl b/src/convenience.jl index 82021c96..cbb8769b 100644 --- a/src/convenience.jl +++ b/src/convenience.jl @@ -10,7 +10,7 @@ Recover Julia object which is attached to user constraint (via constraint data). """ function user_constraint(cons_::Ptr{SCIP_CONS}) @assert cons_ != C_NULL - consdata_::Ptr{SCIP.SCIP_CONSDATA} = SCIPconsGetData(cons_) + consdata_::Ptr{SCIP_CONSDATA} = SCIPconsGetData(cons_) return unsafe_pointer_to_objref(consdata_) end diff --git a/src/cut_selector.jl b/src/cut_selector.jl index cd3813b9..cb60bdeb 100644 --- a/src/cut_selector.jl +++ b/src/cut_selector.jl @@ -48,7 +48,7 @@ function _select_cut_callback( @assert length(cuts) == ncuts forced_cuts = unsafe_wrap(Vector{Ptr{SCIP_ROW}}, forced_cuts_, nforced_cuts) @assert length(forced_cuts) == nforced_cuts - root = root_ == SCIP.TRUE + root = root_ == TRUE (retcode, nselectedcuts, result) = select_cuts( cutsel, scip, @@ -260,7 +260,7 @@ function select_cuts( nselected_cuts = Ref{Cint}(-1) maxparalellism = root ? cutsel.max_parallelism_root : cutsel.max_parallelism max_good_parallelism = max(maxparalellism, 0.5) - retcode = LibSCIP.SCIPselectCutsHybrid( + retcode = SCIPselectCutsHybrid( scip, cuts, forced_cuts, diff --git a/src/event_handler.jl b/src/event_handler.jl index 7bbbaaff..af407976 100644 --- a/src/event_handler.jl +++ b/src/event_handler.jl @@ -1,17 +1,17 @@ # Wrapper for implementing event handlers in SCIP. # Before using please familiaze yourself with https://scipopt.org/doc/html/EVENT.php -# +# # The basic idea here is the same as with the separator wrappers. First, you need # to define a structure that implements the abstract type `AbstractEventhdlr`. # Second you should implement the function `eventexec` where the argument is an # instance of your event handler structure. Third, you should at runtime instantiate # the structure and call `include_event_handler` to register the event handler with SCIP. -# +# # See eventhdlr.jl in the test folder for an example. -# +# abstract type AbstractEventhdlr end -""" +""" This is a virtual function that must be implemented by the user. Its Only argument is the event handler object. """ @@ -80,19 +80,19 @@ function _eventexit( return SCIP_OKAY end """ - include_event_handler(scipd::SCIP.SCIPData, event_handler::EVENTHDLR; name="", desc="") + include_event_handler(scipd::SCIPData, event_handler::EVENTHDLR; name="", desc="") -Include the event handler in SCIP. WARNING! In contrast to the separator wrapper you only need to -pass the SCIPData rather than the SCIP pointer and dictionary. +Include the event handler in SCIP. WARNING! In contrast to the separator wrapper you only need to +pass the SCIPData rather than the SCIP pointer and dictionary. # Arguments -- scipd::SCIP.SCIPData: The SCIPData object +- scipd::SCIPData: The SCIPData object - event_handler::EVENTHDLR: The event handler object - name::String: The name of the event handler - desc::String: The description of the event handler """ function include_event_handler( - scipd::SCIP.SCIPData, + scipd::SCIPData, event_handler::EVENTHDLR; name="", desc="", @@ -130,14 +130,14 @@ function include_event_handler( end """ - catch_event(scipd::SCIP.SCIPData, eventtype::SCIP_EVENTTYPE, eventhdlr::EVENTHDLR) + catch_event(scipd::SCIPData, eventtype::SCIP_EVENTTYPE, eventhdlr::EVENTHDLR) Catch an event in SCIP. This function is a wrapper around the SCIPcatchEvent function. Warning! This function should only be called after the SCIP has been transformed. Use this instead of calling SCIPcatchEvent directly. """ function catch_event( - scipd::SCIP.SCIPData, + scipd::SCIPData, eventtype::SCIP_EVENTTYPE, eventhdlr::EVENTHDLR, ) where {EVENTHDLR<:AbstractEventhdlr} @@ -147,15 +147,15 @@ function catch_event( @SCIP_CALL SCIPcatchEvent(scipd, eventtype, eventhdlrptr, C_NULL, C_NULL) end -""" - drop_event(scipd::SCIP.SCIPData, eventtype::SCIP_EVENTTYPE, eventhdlr::EVENTHDLR) +""" + drop_event(scipd::SCIPData, eventtype::SCIP_EVENTTYPE, eventhdlr::EVENTHDLR) Drop an event in SCIP. This function is a wrapper around the SCIPdropEvent function. Warning! This function should only be called after the SCIP has been transformed. Use this instead of calling SCIPdropEvent directly. """ function drop_event( - scipd::SCIP.SCIPData, + scipd::SCIPData, eventtype::SCIP_EVENTTYPE, eventhdlr::EVENTHDLR, ) where {EVENTHDLR<:AbstractEventhdlr} diff --git a/src/heuristic.jl b/src/heuristic.jl index ed6c52a7..b29d344e 100644 --- a/src/heuristic.jl +++ b/src/heuristic.jl @@ -39,7 +39,7 @@ function _find_primal_solution_callback( ) heurdata::Ptr{SCIP_HEURDATA} = SCIPheurGetData(heur_) heur = unsafe_pointer_to_objref(heurdata) - nodeinfeasible = nodeinfeasible_ == SCIP.TRUE + nodeinfeasible = nodeinfeasible_ == TRUE (retcode, result) = find_primal_solution( scip, heur, diff --git a/src/scip_data.jl b/src/scip_data.jl index 543d4ae6..dbb1fef5 100644 --- a/src/scip_data.jl +++ b/src/scip_data.jl @@ -66,7 +66,7 @@ mutable struct SCIPData @SCIP_CALL SCIPcreate(scip) @assert scip[] != C_NULL @SCIP_CALL SCIPincludeDefaultPlugins(scip[]) - @SCIP_CALL SCIP.SCIPcreateProbBasic(scip[], "") + @SCIP_CALL SCIPcreateProbBasic(scip[], "") scip_data = new( scip, Dict{VarRef,Ref{Ptr{SCIP_VAR}}}(),