From b12276249c8107f613ce437bd1f597702bc9477c Mon Sep 17 00:00:00 2001 From: odow Date: Thu, 18 Jan 2024 20:06:50 +1300 Subject: [PATCH] Some more vale fixes --- .vale.ini | 21 ++++++++++++++++--- .../config/vocabularies/JuMP/accept.txt | 13 ++++++++++++ src/Bridges/Constraint/bridges/geomean.jl | 2 +- .../Constraint/bridges/indicator_sos.jl | 2 +- src/Bridges/Constraint/bridges/quad_to_soc.jl | 2 +- .../Constraint/bridges/set_dot_scaling.jl | 2 +- src/Bridges/Constraint/bridges/slack.jl | 2 +- src/Bridges/Variable/bridges/rsoc_to_psd.jl | 4 ++-- src/Bridges/Variable/bridges/vectorize.jl | 2 +- src/Bridges/bridge.jl | 2 +- src/Bridges/bridge_optimizer.jl | 6 +++--- src/FileFormats/CBF/write.jl | 4 ++-- src/FileFormats/LP/LP.jl | 6 +++--- src/FileFormats/MOF/mof.schema.json | 2 +- src/FileFormats/MPS/MPS.jl | 10 ++++----- src/FileFormats/NL/NL.jl | 2 +- src/FileFormats/NL/NLExpr.jl | 6 +++--- src/FileFormats/SDPA/SDPA.jl | 2 +- src/FileFormats/utils.jl | 4 ++-- .../ReverseAD/forward_over_reverse.jl | 2 +- src/Nonlinear/ReverseAD/graph_tools.jl | 10 ++++----- src/Nonlinear/ReverseAD/reverse_mode.jl | 2 +- src/Nonlinear/ReverseAD/types.jl | 2 +- src/Nonlinear/evaluator.jl | 2 +- src/Nonlinear/operators.jl | 2 +- src/Nonlinear/parse.jl | 2 +- src/Test/Test.jl | 4 ++-- src/Test/test_attribute.jl | 2 +- src/Test/test_conic.jl | 4 ++-- src/Test/test_constraint.jl | 2 +- src/Test/test_modification.jl | 4 ++-- src/Test/test_multiobjective.jl | 4 ++-- src/Test/test_nonlinear.jl | 6 +++--- src/Test/test_solve.jl | 2 +- src/Utilities/CleverDicts.jl | 2 +- src/Utilities/DoubleDicts.jl | 14 ++++++------- src/Utilities/cachingoptimizer.jl | 2 +- src/Utilities/copy.jl | 6 +++--- src/Utilities/distance_to_set.jl | 4 ++-- src/Utilities/functions.jl | 2 +- src/Utilities/matrix_of_constraints.jl | 4 ++-- src/Utilities/mockoptimizer.jl | 4 ++-- src/Utilities/model.jl | 4 ++-- src/Utilities/parser.jl | 9 ++++---- src/Utilities/print.jl | 4 ++-- src/Utilities/results.jl | 4 ++-- src/Utilities/sets.jl | 2 +- src/attributes.jl | 14 ++++++------- src/constraints.jl | 2 +- src/sets.jl | 4 ++-- test/Bridges/Constraint/quad_to_soc.jl | 4 ++-- test/Bridges/bridge_optimizer.jl | 4 ++-- test/FileFormats/LP/LP.jl | 1 - test/Nonlinear/ReverseAD.jl | 4 ++-- test/Utilities/cachingoptimizer.jl | 4 ++-- test/Utilities/print.jl | 2 +- test/Utilities/universalfallback.jl | 12 +++++------ 57 files changed, 141 insertions(+), 115 deletions(-) diff --git a/.vale.ini b/.vale.ini index 532569f8a3..f3d4446a05 100644 --- a/.vale.ini +++ b/.vale.ini @@ -8,15 +8,30 @@ BasedOnStyles = Vale, Google # TODO(odow): fix all of these Google.Ellipses = OFF -Google.Exclamation = OFF Google.FirstPerson = OFF Google.OptionalPlurals = OFF Google.Units = OFF Vale.Spelling = OFF +Google.Quotes = OFF [*.md] BasedOnStyles = Vale, Google [*] -TokenIgnores = (\$.+?\$), \]\(@(ref|id).+?\) -Google.Quotes = OFF +TokenIgnores = (\$+.+?\$+)|(\]\(@(ref|id).+?\)) + +# TODO(odow): investigate + +[docs/src/submodules/Bridges/implementation.md] +Vale.Spelling = OFF + +[docs/src/submodules/Utilities/overview.md] +Vale.Spelling = OFF + +[src/FileFormats/NL/README.md] +Google.FirstPerson = NO + +# Okay to ignore + +[LICENSE.md] +Google.Quotes = NO diff --git a/docs/styles/config/vocabularies/JuMP/accept.txt b/docs/styles/config/vocabularies/JuMP/accept.txt index eaeb0dea6b..02e3094511 100644 --- a/docs/styles/config/vocabularies/JuMP/accept.txt +++ b/docs/styles/config/vocabularies/JuMP/accept.txt @@ -1,5 +1,8 @@ % Julia-related vocab api|API +[Aa]rgs +attr +kwargs arXiv backports blogposts @@ -14,10 +17,14 @@ getters [Jj]ulia linkcheck nonlinearly +nonzeros [Pp]recompil(ation|(e(?d))) +Stacktrace subexpression(?s) sublicense +supertype textualist +untyped % JuMP-related vocab [Cc]anonicaliz(e|ation|ing) @@ -29,10 +36,15 @@ Presolve [Ss]emidefinite unboundedness [Un]nivariate +unary % Other +Alizadeh +Arkadi +Cholesky Codecov Clp +Goldfarb Gurobi GZip Holy @@ -41,3 +53,4 @@ MOI PATHSolver preprint Lubin +Nemirovski diff --git a/src/Bridges/Constraint/bridges/geomean.jl b/src/Bridges/Constraint/bridges/geomean.jl index f1a4868c51..e7adf77262 100644 --- a/src/Bridges/Constraint/bridges/geomean.jl +++ b/src/Bridges/Constraint/bridges/geomean.jl @@ -61,7 +61,7 @@ struct GeoMeanBridge{T,F,G,H} <: AbstractBridge xij::Vector{MOI.VariableIndex} t_upper_bound_constraint::MOI.ConstraintIndex{F,MOI.LessThan{T}} rsoc_constraints::Vector{MOI.ConstraintIndex{G,MOI.RotatedSecondOrderCone}} - # Ihe case that `d > 2`, this is `Nothing` because the new variables are + # In the case that `d > 2`, this is `Nothing` because the new variables are # non-negative due to the RotatedSecondOrderCone constraint. x_nonnegative_constraint::Union{ Nothing, diff --git a/src/Bridges/Constraint/bridges/indicator_sos.jl b/src/Bridges/Constraint/bridges/indicator_sos.jl index e1750df50c..c0148eaa01 100644 --- a/src/Bridges/Constraint/bridges/indicator_sos.jl +++ b/src/Bridges/Constraint/bridges/indicator_sos.jl @@ -52,7 +52,7 @@ function bridge_constraint( sos_index = MOI.add_constraint( model, MOI.VectorOfVariables([slack, z]), - MOI.SOS1{T}([0.4, 0.6]), # This weight vector is arbitrary! + MOI.SOS1{T}([0.4, 0.6]), # This weight vector is arbitrary ) new_f = MOI.Utilities.operate(+, T, f_scalars[2], slack) affine_index = MOI.add_constraint(model, new_f, s.set) diff --git a/src/Bridges/Constraint/bridges/quad_to_soc.jl b/src/Bridges/Constraint/bridges/quad_to_soc.jl index c11ccca1ee..98364a5dcb 100644 --- a/src/Bridges/Constraint/bridges/quad_to_soc.jl +++ b/src/Bridges/Constraint/bridges/quad_to_soc.jl @@ -346,7 +346,7 @@ end # where Q = U^T * U$, we have `x = U * z` and `s = -a^T z - b` hence, we have # = -u * (z^T Q z/2 + a^T z + b) # So the dual of the quadratic constraint is `-u`, so that the contribution -# to the lagrangian function of both the quadratic and RotatedSOC formulation +# to the Lagrangian function of both the quadratic and RotatedSOC formulation # is exactly the same. function MOI.get( model::MOI.ModelLike, diff --git a/src/Bridges/Constraint/bridges/set_dot_scaling.jl b/src/Bridges/Constraint/bridges/set_dot_scaling.jl index 36cee0f65f..9fff52e8ba 100644 --- a/src/Bridges/Constraint/bridges/set_dot_scaling.jl +++ b/src/Bridges/Constraint/bridges/set_dot_scaling.jl @@ -93,7 +93,7 @@ end # scalar product for the scaled PSD cone is `_2 = x'y` but the scalar # product for the PSD cone additionally scales the offdiagonal entries by `2` # hence by `D^2` so `_1 = x'D^2y`. -# So `_2 = _1` hence the adjoint of `D` is its inverse! +# So `_2 = _1` hence the adjoint of `D` is its inverse. function MOI.Bridges.adjoint_map_function( ::Type{<:SetDotScalingBridge{T,S}}, func, diff --git a/src/Bridges/Constraint/bridges/slack.jl b/src/Bridges/Constraint/bridges/slack.jl index f451bb1a20..4109d9ccbf 100644 --- a/src/Bridges/Constraint/bridges/slack.jl +++ b/src/Bridges/Constraint/bridges/slack.jl @@ -141,7 +141,7 @@ function MOI.set( # As the slack appears `+slack` in `slack_in_set` and `-slack` in equality, # giving `value` to both will cancel it out in the Lagrangian. # Giving `value` to `bridge.equality` will put the function in the - # lagrangian as expected. + # Lagrangian as expected. MOI.set(model, attr, bridge.slack_in_set, value) MOI.set(model, attr, bridge.equality, value) return diff --git a/src/Bridges/Variable/bridges/rsoc_to_psd.jl b/src/Bridges/Variable/bridges/rsoc_to_psd.jl index aeaa4b3154..cc3b30ca86 100644 --- a/src/Bridges/Variable/bridges/rsoc_to_psd.jl +++ b/src/Bridges/Variable/bridges/rsoc_to_psd.jl @@ -14,7 +14,7 @@ ``Y = \\left[\\begin{array}{c c}t & x^\\top \\\\ x & 2u \\mathbf{I}\\end{array}\\right].`` Additional bounds are added to ensure the off-diagonals of the ``2uI`` submatrix -are `0`, and linear constraints are added to ennsure the diagonal of ``2uI`` +are `0`, and linear constraints are added to ensure the diagonal of ``2uI`` takes the same values. As a special case, if ``|x|| = 0``, then `RSOCtoPSDBridge` reformulates into @@ -36,7 +36,7 @@ As a special case, if ``|x|| = 0``, then `RSOCtoPSDBridge` reformulates into * [`MOI.VectorOfVariables`](@ref) in [`MOI.PositiveSemidefiniteConeTriangle`](@ref) otherwise * The constraint node [`MOI.VariableIndex`](@ref) in [`MOI.EqualTo`](@ref) - * The constrant node [`MOI.ScalarAffineFunction`](@ref) in [`MOI.EqualTo`](@ref) + * The constant node [`MOI.ScalarAffineFunction`](@ref) in [`MOI.EqualTo`](@ref) """ struct RSOCtoPSDBridge{T} <: AbstractBridge variables::Vector{MOI.VariableIndex} diff --git a/src/Bridges/Variable/bridges/vectorize.jl b/src/Bridges/Variable/bridges/vectorize.jl index 7d60f3fe4d..efe8a5ab59 100644 --- a/src/Bridges/Variable/bridges/vectorize.jl +++ b/src/Bridges/Variable/bridges/vectorize.jl @@ -124,7 +124,7 @@ function MOI.set( bridge::VectorizeBridge, ::MOI.Utilities.ScalarLinearSet, ) - # This would require modifing any constraint which uses the bridged + # This would require modifying any constraint which uses the bridged # variable. return throw( MOI.SetAttributeNotAllowed( diff --git a/src/Bridges/bridge.jl b/src/Bridges/bridge.jl index eec27a974d..f3748db176 100644 --- a/src/Bridges/bridge.jl +++ b/src/Bridges/bridge.jl @@ -274,7 +274,7 @@ needs_final_touch(::AbstractBridge) = false final_touch(bridge::AbstractBridge, model::MOI.ModelLike)::Nothing A function that is called immediately prior to [`MOI.optimize!`](@ref) to allow -bridges to modify their reformulations with repsect to other variables and +bridges to modify their reformulations with respect to other variables and constraints in `model`. For example, if the correctness of `bridge` depends on the bounds of a variable diff --git a/src/Bridges/bridge_optimizer.jl b/src/Bridges/bridge_optimizer.jl index c064269614..a5b5a363b0 100644 --- a/src/Bridges/bridge_optimizer.jl +++ b/src/Bridges/bridge_optimizer.jl @@ -2205,7 +2205,7 @@ function bridged_function(bridge::AbstractBridgeOptimizer, value) end # We assume that the type of `value` is not altered. This restricts # variable bridges to only return `ScalarAffineFunction` but otherwise, - # the peformance would be bad. + # the performance would be bad. return MOI.Utilities.substitute_variables( vi -> bridged_variable_function(bridge, vi), value, @@ -2383,9 +2383,9 @@ function unbridged_constraint_function( # Otherwise, first unbridge the function: f = unbridged_function(b, func)::typeof(func) # But now we have to deal with an issue. Something like x in [1, ∞) might - # get bridged into y in R₊, with x => y + 1, so if the orginal constraint is + # get bridged into y in R₊, with x => y + 1, so if the original constraint is # 2x >= 1, the bridged function is 2y >= -1. Unbridging this with y = x - 1 - # gives 2x - 2, but we only care about 2x! Where did the -2 come from? It + # gives 2x - 2, but we only care about 2x. Where did the -2 come from? It # was moved into the set. This gets handled separately, so for # ConstraintFunction it is sufficient to drop any non-zero constant terms. # diff --git a/src/FileFormats/CBF/write.jl b/src/FileFormats/CBF/write.jl index 90a17b557b..2bc4e26541 100644 --- a/src/FileFormats/CBF/write.jl +++ b/src/FileFormats/CBF/write.jl @@ -84,7 +84,7 @@ function _add_function( f::MOI.VectorOfVariables, ::Type{<:Union{MOI.ExponentialCone,MOI.DualExponentialCone}}, ) - # The Exponential cone in MOI and CBF are reversed! + # The Exponential cone in MOI and CBF are reversed for v in reverse(f.variables) data.num_rows += 1 push!(data.acoord, (data.num_rows, v.value, 1.0)) @@ -97,7 +97,7 @@ function _add_function( f::MOI.VectorAffineFunction, ::Type{<:Union{MOI.ExponentialCone,MOI.DualExponentialCone}}, ) - # The Exponential cone in MOI and CBF are reversed! + # The Exponential cone in MOI and CBF are reversed for term in f.terms t = term.scalar_term row = data.num_rows + 4 - term.output_index diff --git a/src/FileFormats/LP/LP.jl b/src/FileFormats/LP/LP.jl index 28187d9523..a7e7d8e981 100644 --- a/src/FileFormats/LP/LP.jl +++ b/src/FileFormats/LP/LP.jl @@ -401,7 +401,7 @@ end # ============================================================================== # -# Base.read! +# `Base.read!` # # ============================================================================== @@ -541,7 +541,7 @@ function _get_term(token_types, token_values, offset) error("Invalid line") end if offset > length(token_types) || token_types[offset] == _TOKEN_SIGN - return coef, offset # It's a standalone constant! + return coef, offset # It's a standalone constant end if token_types[offset] == _TOKEN_QUADRATIC_OPEN return _get_term(token_types, token_values, offset + 1) @@ -588,7 +588,7 @@ function _parse_function( else @assert token_type == _TOKEN_VARIABLE x = _get_variable_from_name(model, cache, token::String) - # A cheat for type-stability. Store `Float64` of the variable index! + # A cheat for type-stability. Store `Float64` of the variable index token_values[i] = Float64(x.value) end end diff --git a/src/FileFormats/MOF/mof.schema.json b/src/FileFormats/MOF/mof.schema.json index 2679c22791..44e9b52f7f 100644 --- a/src/FileFormats/MOF/mof.schema.json +++ b/src/FileFormats/MOF/mof.schema.json @@ -1133,7 +1133,7 @@ } } }, { - "description": "The set `{(c, y, x) in Z^{1+1+d}}`, such that `c` is strictly greater than the number of occurances of `y` in `x` and `dimension = 1 + 1 + d`.", + "description": "The set `{(c, y, x) in Z^{1+1+d}}`, such that `c` is strictly greater than the number of occurences of `y` in `x` and `dimension = 1 + 1 + d`.", "examples": ["{\"type\": \"CountGreaterThan\", \"dimension\": 3}"], "required": ["dimension"], "properties": { diff --git a/src/FileFormats/MPS/MPS.jl b/src/FileFormats/MPS/MPS.jl index 7496aa2174..b732ab468c 100644 --- a/src/FileFormats/MPS/MPS.jl +++ b/src/FileFormats/MPS/MPS.jl @@ -489,7 +489,7 @@ function write_columns(io::IO, model::Model, flip_obj, ordered_names, names) int_open = false end if length(coefficients[variable]) == 0 - # Every variable must appear in the COLUMNS section! Add a 0 + # Every variable must appear in the COLUMNS section. Add a 0 # objective coefficient instead. println(io, Card(f2 = variable, f3 = "OBJ", f4 = "0")) end @@ -906,7 +906,7 @@ end # ============================================================================== # -# Base.read! +# `Base.read!` # # Here is a template for an MPS file, reproduced from # http://lpsolve.sourceforge.net/5.5/mps-format.htm. @@ -1024,7 +1024,7 @@ end HEADER_INDICATORS, ) -# `Headers(s)` gets called _alot_ (on every line), so we try very hard to be +# `Headers` gets called _alot_ (on every line), so we try very hard to be # efficient. function Headers(s::AbstractString) N = length(s) @@ -1687,7 +1687,7 @@ function parse_qmatrix_line(data, items) error("Malformed QMATRIX line: $(join(items, " "))") end if data.name_to_col[items[1]] <= data.name_to_col[items[2]] - # Off-diagonals have duplicate entries! We don't need to store both + # Off-diagonals have duplicate entries. We don't need to store both # triangles. push!(data.quad_obj, (items[1], items[2], parse(Float64, items[3]))) end @@ -1703,7 +1703,7 @@ function parse_qcmatrix_line(data, items) error("Malformed QCMATRIX line: $(join(items, " "))") end if data.name_to_col[items[1]] <= data.name_to_col[items[2]] - # Off-diagonals have duplicate entries! We don't need to store both + # Off-diagonals have duplicate entries. We don't need to store both # triangles. push!( data.qc_matrix[data.current_qc_matrix], diff --git a/src/FileFormats/NL/NL.jl b/src/FileFormats/NL/NL.jl index 8fd30aebe1..5a528e7f7a 100644 --- a/src/FileFormats/NL/NL.jl +++ b/src/FileFormats/NL/NL.jl @@ -296,7 +296,7 @@ function MOI.copy_to(dest::Model, model::MOI.ModelLike) end # Correct bounds of binary variables. Mainly because AMPL doesn't have the # concept of binary nonlinear variables, but it does have binary linear - # variables! How annoying. + # variables. How annoying. for (_, v) in dest.x if v.type == _BINARY v.lower = max(0.0, v.lower) diff --git a/src/FileFormats/NL/NLExpr.jl b/src/FileFormats/NL/NLExpr.jl index b92adf9ee3..0ea5e07eca 100644 --- a/src/FileFormats/NL/NLExpr.jl +++ b/src/FileFormats/NL/NLExpr.jl @@ -384,7 +384,7 @@ function _process_expr!(expr::_NLExpr, arg::MOI.VariableIndex) return push!(expr.nonlinear_terms, arg) end -# TODO(odow): these process_expr! functions use recursion. For large models, +# TODO(odow): these functions use recursion. For large models, # this may exceed the stack. At some point, we may have to rewrite this to not # use recursion. function _process_expr!(expr::_NLExpr, arg::Expr) @@ -443,7 +443,7 @@ function _process_expr!(expr::_NLExpr, args::Vector{Any}) if op == :+ if N == 1 # +x, so we can just drop the op and process the args. return _process_expr!(expr, args[2]) - elseif N > 2 # nary-addition! + elseif N > 2 # nary-addition op = :sum end elseif op == :- && N == 1 @@ -458,7 +458,7 @@ function _process_expr!(expr::_NLExpr, args::Vector{Any}) N = length(args) - 1 end elseif op == :* && N == 1 - # Unary multiplication! We can drop the op and process the args. + # unary multiplication: we can drop the op and process the args. return _process_expr!(expr, args[2]) end # Now convert the Julia expression into an _NLExpr. diff --git a/src/FileFormats/SDPA/SDPA.jl b/src/FileFormats/SDPA/SDPA.jl index 8599013bf5..0c03177060 100644 --- a/src/FileFormats/SDPA/SDPA.jl +++ b/src/FileFormats/SDPA/SDPA.jl @@ -280,7 +280,7 @@ end # ============================================================================== # -# Base.read! +# `Base.read!` # # ============================================================================== diff --git a/src/FileFormats/utils.jl b/src/FileFormats/utils.jl index d6abbb875b..efe584bf8a 100644 --- a/src/FileFormats/utils.jl +++ b/src/FileFormats/utils.jl @@ -88,7 +88,7 @@ function create_unique_constraint_names( replacements, ) if new_name in added_names - # We found a duplicate name! We could just append a string like + # We found a duplicate name. We could just append a string like # "_", but we're going to be clever and loop through the # integers to name them appropriately. Thus, if we have three # constraints named c, we'll end up with variables named c, c_1, @@ -145,7 +145,7 @@ function create_unique_variable_names( replacements, ) if new_name in added_names - # We found a duplicate name! We could just append a string like "_", + # We found a duplicate name. We could just append a string like "_", # but we're going to be clever and loop through the integers to name # them appropriately. Thus, if we have three variables named x, # we'll end up with variables named x, x_1, and x_2. diff --git a/src/Nonlinear/ReverseAD/forward_over_reverse.jl b/src/Nonlinear/ReverseAD/forward_over_reverse.jl index cddfee697f..71d61767ac 100644 --- a/src/Nonlinear/ReverseAD/forward_over_reverse.jl +++ b/src/Nonlinear/ReverseAD/forward_over_reverse.jl @@ -232,7 +232,7 @@ function _forward_eval_ϵ( @inbounds partial = ex.partials_storage[ix] @inbounds storage_val = storage_ϵ[ix] # TODO: This "if" statement can take 8% of the hessian - # evaluation time! Find a more efficient way. + # evaluation time. Find a more efficient way. if !isfinite(partial) && storage_val == zero_ϵ continue end diff --git a/src/Nonlinear/ReverseAD/graph_tools.jl b/src/Nonlinear/ReverseAD/graph_tools.jl index 4950cd887b..8df78cf26c 100644 --- a/src/Nonlinear/ReverseAD/graph_tools.jl +++ b/src/Nonlinear/ReverseAD/graph_tools.jl @@ -10,7 +10,7 @@ moi_index_to_consecutive_index::Dict{MOI.VariableIndex,Int}, ) -Return a new `Vector{Nonlinear.Node}` where all occurances of +Return a new `Vector{Nonlinear.Node}` where all occurences of `NODE_MOI_VARIABLE` are replaced by `NODE_VARIABLE` that is 1-indexed and ordered. """ @@ -356,7 +356,7 @@ end Vector{Vector{Int}}(undef, length(subexpressions)), ) -Return a topologically sorted list of the integer subexpresssion indices that +Return a topologically sorted list of the integer subexpression indices that need to be computed to evaluate `subexpressions[s]` for all `s in starts`. `starts` should be ordered, and not contain duplicates. @@ -369,14 +369,14 @@ If calling `_topological_sort` a single time, you may omit the `subexpression_dependency_graph` argument. However, if calling `_topological_sort` multiple times on the _same_ vector of -subexpresssions, you should create `subexpression_dependency_graph` once (either +subexpressions, you should create `subexpression_dependency_graph` once (either as the uninitialized vector, or by explicitly computing the full `subexpression_dependency_graph`), and pass it in. ## Notes * It is important to not use recursion here, because expressions may have - arbitrary levels of nesting! + arbitrary levels of nesting. * This function assumes `subexpressions` is acyclic. """ function _topological_sort( @@ -441,7 +441,7 @@ Returns two things: subexpression-indices that need to be evaluated to compute `main_expressions[i]`. -**Warning:** This doesn't handle cyclic expressions! But this should be fine +**Warning:** This doesn't handle cyclic expressions. But this should be fine because we can't compute them in JuMP anyway. """ function _order_subexpressions( diff --git a/src/Nonlinear/ReverseAD/reverse_mode.jl b/src/Nonlinear/ReverseAD/reverse_mode.jl index ba5b73a92a..ca7fa1e0f8 100644 --- a/src/Nonlinear/ReverseAD/reverse_mode.jl +++ b/src/Nonlinear/ReverseAD/reverse_mode.jl @@ -13,7 +13,7 @@ This function updates many of the data-structures inside `d` in-place. At a high level, reverse-mode AD has two phases: -In Phase I, we evalute the problem in `d` at the primal solution `x`, and +In Phase I, we evaluate the problem in `d` at the primal solution `x`, and stores the primal solution of each expression in the tree and the first-order partial derivative information for each node with respect to its arguments. diff --git a/src/Nonlinear/ReverseAD/types.jl b/src/Nonlinear/ReverseAD/types.jl index 6f2163708f..6f43c6773c 100644 --- a/src/Nonlinear/ReverseAD/types.jl +++ b/src/Nonlinear/ReverseAD/types.jl @@ -164,7 +164,7 @@ mutable struct NLPEvaluator <: MOI.AbstractNLPEvaluator # reverse-mode automatic differentiation. last_x::Vector{Float64} - # Temporary storage for computing jacobians. This is also used as temporary + # Temporary storage for computing Jacobians. This is also used as temporary # storage for the input of multivariate functions. jac_storage::Vector{Float64} # Temporary storage for the gradient of multivariate functions diff --git a/src/Nonlinear/evaluator.jl b/src/Nonlinear/evaluator.jl index f551e136c7..c34566d3d3 100644 --- a/src/Nonlinear/evaluator.jl +++ b/src/Nonlinear/evaluator.jl @@ -276,7 +276,7 @@ If `moi_output_format = true`: If `moi_output_format = false`: * subexpressions will be represented by a [`ExpressionIndex`](@ref) object. * parameters will be represented by a [`ParameterIndex`](@ref) object. - * variables will be represennted by an [`MOI.VariableIndex`](@ref) object. + * variables will be represented by an [`MOI.VariableIndex`](@ref) object. !!! warning To use `moi_output_format = true`, you must have first called diff --git a/src/Nonlinear/operators.jl b/src/Nonlinear/operators.jl index 40e667a195..a0d4bc0e9c 100644 --- a/src/Nonlinear/operators.jl +++ b/src/Nonlinear/operators.jl @@ -896,7 +896,7 @@ function eval_comparison_function( end end -# This method is implmented here because it needs the OperatorRegistry type from +# This method is implemented here because it needs the OperatorRegistry type from # the Nonlinear, which doesn't exist when the Utilities submodule is defined. function MOI.Utilities.eval_variables( diff --git a/src/Nonlinear/parse.jl b/src/Nonlinear/parse.jl index 77ecdedb06..40ca613903 100644 --- a/src/Nonlinear/parse.jl +++ b/src/Nonlinear/parse.jl @@ -329,7 +329,7 @@ Convert the [`Expression`](@ref) `expr` into a Julia `Expr`. * subexpressions are represented by a [`ExpressionIndex`](@ref) object. * parameters are represented by a [`ParameterIndex`](@ref) object. - * variables are represennted by an [`MOI.VariableIndex`](@ref) object. + * variables are represented by an [`MOI.VariableIndex`](@ref) object. """ function convert_to_expr(model::Model, expr::Expression) tree = Any[] diff --git a/src/Test/Test.jl b/src/Test/Test.jl index 0e73cf801d..44ea0376ba 100644 --- a/src/Test/Test.jl +++ b/src/Test/Test.jl @@ -266,7 +266,7 @@ function runtests( @testset "$(name)" begin c = copy(config) tear_down = setup_test(test_function, model, c) - # Make sure to empty the model before every test! + # Make sure to empty the model before every test. MOI.empty!(model) try test_function(model, c) @@ -623,7 +623,7 @@ function util_test_models_equal( end ### -### Include all the test files! +### Include all the test files ### for file in readdir(@__DIR__) diff --git a/src/Test/test_attribute.jl b/src/Test/test_attribute.jl index 8b8ff0e2f9..6b83ff858f 100644 --- a/src/Test/test_attribute.jl +++ b/src/Test/test_attribute.jl @@ -332,7 +332,7 @@ function test_attribute_after_empty(model::MOI.AbstractOptimizer, ::Config) MOI.empty!(model) @test MOI.get(model, MOI.Silent()) == value end - # Make sure to reset the value before leaving this function! + # Make sure to reset the value before leaving this function MOI.set(model, MOI.Silent(), current) return end diff --git a/src/Test/test_conic.jl b/src/Test/test_conic.jl index 152a1f9c90..b2dca3f3da 100644 --- a/src/Test/test_conic.jl +++ b/src/Test/test_conic.jl @@ -6726,7 +6726,7 @@ end config::Config{T}, ) where {T<:Real} -Test a second order cosnstraint with an epigraph variable >= -M and the bound +Test a second order constraint with an epigraph variable >= -M and the bound constraints added via `add_constraint`. """ function test_conic_SecondOrderCone_negative_post_bound_2( @@ -6790,7 +6790,7 @@ end config::Config{T}, ) where {T<:Real} -Test a second order cosnstraint with an epigraph variable >= -M and the bound +Test a second order constraint with an epigraph variable >= -M and the bound constraints added via `add_constraints`. """ function test_conic_SecondOrderCone_negative_post_bound_3( diff --git a/src/Test/test_constraint.jl b/src/Test/test_constraint.jl index ae512a3403..53d1ae49e0 100644 --- a/src/Test/test_constraint.jl +++ b/src/Test/test_constraint.jl @@ -460,7 +460,7 @@ The problem is `max x + 2y | x^2 + 0.25y*x + 0.25x*y + 0.5x*y + y^2 <= 1, x >= 0.5, y >= 0.5`. !!! warn - This problem has an irrational solution! Solvers using rational arithmetic + This problem has an irrational solution. Solvers using rational arithmetic should exclude it. """ function test_constraint_qcp_duplicate_off_diagonal( diff --git a/src/Test/test_modification.jl b/src/Test/test_modification.jl index 25da71e006..1270d9bdb6 100644 --- a/src/Test/test_modification.jl +++ b/src/Test/test_modification.jl @@ -645,8 +645,8 @@ end config::Config, ) -Test the constant of a scalaraffine objective. If `config.solve=true` confirm -that it solves correctly. +Test the constant of a ScalarAffineFunction objective. If `config.solve=true` +confirm that it solves correctly. """ function test_modification_const_scalar_objective( model::MOI.ModelLike, diff --git a/src/Test/test_multiobjective.jl b/src/Test/test_multiobjective.jl index c33b4d14b5..9a0630e61f 100644 --- a/src/Test/test_multiobjective.jl +++ b/src/Test/test_multiobjective.jl @@ -52,7 +52,7 @@ function test_multiobjective_vector_of_variables_delete_all( @test MOI.get(model, MOI.ObjectiveFunction{F}()) == MOI.VectorOfVariables([x[2]]) MOI.delete(model, x[2]) - # ObjectiveFunction no longer set because we deleted all the variables! + # ObjectiveFunction no longer set because we deleted all the variables attributes = MOI.get(model, MOI.ListOfModelAttributesSet()) @test !(MOI.ObjectiveFunction{F}() in attributes) return @@ -73,7 +73,7 @@ function test_multiobjective_vector_of_variables_delete_vector( attributes = MOI.get(model, MOI.ListOfModelAttributesSet()) @test MOI.ObjectiveFunction{F}() in attributes MOI.delete(model, x) - # ObjectiveFunction no longer set because we deleted all the variables! + # ObjectiveFunction no longer set because we deleted all the variables attributes = MOI.get(model, MOI.ListOfModelAttributesSet()) @test !(MOI.ObjectiveFunction{F}() in attributes) return diff --git a/src/Test/test_nonlinear.jl b/src/Test/test_nonlinear.jl index d7dacbf610..575c2af642 100644 --- a/src/Test/test_nonlinear.jl +++ b/src/Test/test_nonlinear.jl @@ -972,12 +972,12 @@ function test_nonlinear_HS071_internal(::MOI.ModelLike, ::Config) J = fill(NaN, length(Js)) MOI.eval_constraint_jacobian(d, J, x) @test J == [1, 1, 1, 1, 2, 2, 2, 2] - # Hessian-lagrangian + # Hessian-Lagrangian Hs = MOI.hessian_lagrangian_structure(d) H = fill(NaN, length(Hs)) MOI.eval_hessian_lagrangian(d, H, x, 1.0, [1.0, 1.0]) @test H == [4, 2, 2, 2, 1, 2, 5, 2, 2, 2] - # Hessian-lagrangian-product + # Hessian-Lagrangian-product Hv = fill(NaN, length(x)) v = [1.0, 1.1, 1.2, 1.3] MOI.eval_hessian_lagrangian_product(d, Hv, x, v, 1.0, [1.0, 1.0]) @@ -1016,7 +1016,7 @@ function test_nonlinear_Feasibility_internal(::MOI.ModelLike, ::Config) J = fill(NaN, length(Js)) MOI.eval_constraint_jacobian(d, J, x) @test J == [3.0] - # Hessian-lagrangian + # Hessian-Lagrangian Hs = MOI.hessian_lagrangian_structure(d) H = fill(NaN, length(Hs)) MOI.eval_hessian_lagrangian(d, H, x, 1.0, [1.1]) diff --git a/src/Test/test_solve.jl b/src/Test/test_solve.jl index 127df14d37..b4eb577706 100644 --- a/src/Test/test_solve.jl +++ b/src/Test/test_solve.jl @@ -1199,7 +1199,7 @@ end """ test_solve_conflict_NOT_IN_CONFLICT(model::MOI.ModelLike, config::Config{T}) where {T} -Test the ConflictStatus API when some constraints are not in the conlict. +Test the ConflictStatus API when some constraints are not in the conflict. """ function test_solve_conflict_NOT_IN_CONFLICT( model::MOI.ModelLike, diff --git a/src/Utilities/CleverDicts.jl b/src/Utilities/CleverDicts.jl index 6bd7bfc37d..d12a793867 100644 --- a/src/Utilities/CleverDicts.jl +++ b/src/Utilities/CleverDicts.jl @@ -230,7 +230,7 @@ function Base.getindex(c::CleverDict{K,V}, index::LinearIndex)::V where {K,V} # (that is, there has been a deletion), rebuild `c.vector`. This is a # trade-off: We could ensure `c.vector` is always updated, but this requires # a `splice!` in `delete!`, making deletions costly. However, it makes this - # `getindex` operation trival because we would never have to rebuild the + # `getindex` operation trivial because we would never have to rebuild the # vector. # The current implemented approach offers quick deletions, but an expensive # rebuild the first time you query a `LinearIndex` after a deletion or a new diff --git a/src/Utilities/DoubleDicts.jl b/src/Utilities/DoubleDicts.jl index b7292f9c44..872256a9a3 100644 --- a/src/Utilities/DoubleDicts.jl +++ b/src/Utilities/DoubleDicts.jl @@ -110,7 +110,7 @@ function typed_value(::IndexDoubleDictInner{F,S}, v::Int64) where {F,S} return MOI.ConstraintIndex{F,S}(v) end -# Base.sizehint! +# `Base.sizehint!` function Base.sizehint!(::AbstractDoubleDict, ::Integer) return throw( @@ -193,7 +193,7 @@ function Base.getindex( return typed_value(d, x) end -# Base.setindex! +# `Base.setindex!` function Base.setindex!( d::AbstractDoubleDict{V}, @@ -233,7 +233,7 @@ function Base.setindex!( return value end -# Base.empty! +# `Base.empty!` function Base.empty!(d::AbstractDoubleDict) Base.empty!(d.dict) @@ -245,7 +245,7 @@ function Base.empty!(d::AbstractDoubleDictInner) return d end -# Base.delete! +# `Base.delete!` function Base.delete!( d::AbstractDoubleDict, @@ -312,7 +312,7 @@ end ``` For performance, it is recommended that the inner loop lies in a separate -function to gurantee type-stability. +function to guarantee type-stability. Some outer keys `(F, S)` might lead to an empty `dict[F, S]`. If you want only nonempty `dict[F, S]`, use [`nonempty_outer_keys`](@ref). """ @@ -334,7 +334,7 @@ for (F, S) in DoubleDicts.nonempty_outer_keys(dict) end end For performance, it is recommended that the inner loop lies in a separate -function to gurantee type-stability. +function to guarantee type-stability. If you want an iterator of all current outer keys, use [`outer_keys`](@ref). ``` @@ -357,7 +357,7 @@ function Base.iterate(d::AbstractDoubleDict) ((F, S), inner), outer_state = outer_next inner_next = iterate(inner) while inner_next === nothing - # It may be that the inner dictionary is empty! If so, we should go to + # It may be that the inner dictionary is empty. If so, we should go to # the next element in the outer dictionary. outer_next = iterate(d.dict, outer_state) if outer_next === nothing diff --git a/src/Utilities/cachingoptimizer.jl b/src/Utilities/cachingoptimizer.jl index 4646a2c94e..a63e265ec7 100644 --- a/src/Utilities/cachingoptimizer.jl +++ b/src/Utilities/cachingoptimizer.jl @@ -303,7 +303,7 @@ function MOI.optimize!(m::CachingOptimizer) if m.mode == AUTOMATIC && m.state == EMPTY_OPTIMIZER final_touch(m.model_cache, nothing) # Here is a special case for callbacks: we can't use the two-argument - # call to optimize! because we need the `optimizer_to_model_map` to be + # call to `optimize!` because we need the `optimizer_to_model_map` to be # set _prior_ to starting the optimization process. Therefore, we need # to check if we have an `AbstractCallback` set and attach the optimizer # before recalling `MOI.optimize!`. diff --git a/src/Utilities/copy.jl b/src/Utilities/copy.jl index fb12255577..b5af3284e3 100644 --- a/src/Utilities/copy.jl +++ b/src/Utilities/copy.jl @@ -447,7 +447,7 @@ If the order is `[GreaterThan, Integer]`, then we add a new variable constrained to `y ∈ Nonnegatives` and end up with an expression from the variable bridge of `x = y + 1`. Then when we add the Integer constraint, we get `y + 1 in Integer`, which is not natively supported. Therefore, we need to add `y + 1 - z ∈ Zeros` -and `z ∈ Integer`. Oops! This cost an extra variable, a variable bridge of +and `z ∈ Integer`. Oops. This cost an extra variable, a variable bridge of `x = y + 1`and a `Zeros` constraint. Unfortunately, we don't have a good way of computing the updated costs for other @@ -557,7 +557,7 @@ MOI.copy_to(dest, filtered_src) Use type dispatch to simplify the implementation: ```julia -my_filter(::Any) = true # Note the generic fallback! +my_filter(::Any) = true # Note the generic fallback my_filter(::MOI.VariableName) = false my_filter(::MOI.ConstraintName) = false filtered_src = MOI.Utilities.ModelFilter(my_filter, src) @@ -567,7 +567,7 @@ MOI.copy_to(dest, filtered_src) ## Example: copy irreducible infeasible subsystem ```julia -my_filter(::Any) = true # Note the generic fallback! +my_filter(::Any) = true # Note the generic fallback function my_filter(ci::MOI.ConstraintIndex) status = MOI.get(dest, MOI.ConstraintConflictStatus(), ci) return status != MOI.NOT_IN_CONFLICT diff --git a/src/Utilities/distance_to_set.jl b/src/Utilities/distance_to_set.jl index d1848e9091..3dc1464d4d 100644 --- a/src/Utilities/distance_to_set.jl +++ b/src/Utilities/distance_to_set.jl @@ -7,7 +7,7 @@ """ abstract type AbstractDistance end -An abstract type used to enabble dispatch of +An abstract type used to enable dispatch of [`Utilities.distance_to_set`](@ref). """ abstract type AbstractDistance end @@ -219,7 +219,7 @@ function distance_to_set( # trends in Optimization, page 184, section 6.3.2. t, rhs = x[1], LinearAlgebra.norm(@views x[2:end]) if t >= rhs - return zero(T) # The point is feasible! + return zero(T) # The point is feasible end if rhs <= -t # Projection to the point (0, [0]) return LinearAlgebra.norm(x) diff --git a/src/Utilities/functions.jl b/src/Utilities/functions.jl index a0e1bd0123..0452b8bb85 100644 --- a/src/Utilities/functions.jl +++ b/src/Utilities/functions.jl @@ -942,7 +942,7 @@ is_canonical(::MOI.AbstractFunction) = false is_canonical(::Union{MOI.VariableIndex,MOI.VectorOfVariables}) = true function is_canonical(f::MOI.ScalarNonlinearFunction) - # Don't use recursion here! This gets called for all scalar nonlinear + # Don't use recursion here. This gets called for all scalar nonlinear # constraints. stack = Any[arg for arg in f.args] while !isempty(stack) diff --git a/src/Utilities/matrix_of_constraints.jl b/src/Utilities/matrix_of_constraints.jl index 0e695375e5..921dd820ac 100644 --- a/src/Utilities/matrix_of_constraints.jl +++ b/src/Utilities/matrix_of_constraints.jl @@ -544,8 +544,8 @@ end ### .constants::Vector ### -# Base.empty! is already implemented. -# Base.resize! is already implemented. +# `Base.empty!` is already implemented. +# `Base.resize!` is already implemented. function load_constants( b::Vector{T}, diff --git a/src/Utilities/mockoptimizer.jl b/src/Utilities/mockoptimizer.jl index 7d1b5cc138..81bad27593 100644 --- a/src/Utilities/mockoptimizer.jl +++ b/src/Utilities/mockoptimizer.jl @@ -964,7 +964,7 @@ end """ set_mock_optimize!(mock::MockOptimizer, opt::Function...) -Sets multiple optimize! function. The first is to be used the first time +Sets multiple `optimize!` functions. The first is to be used the first time `MOI.optimize!(mock)` is called, the second function is to be used the second time, ... """ @@ -1014,7 +1014,7 @@ solution. `MOI.ListOfVariableIndices`. * `dual_status`: corresponds to the `MOI.DualStatus` attribute. If not - provided, it defaults to `MOI.FEASIBLE_POINT` if constriant duals are + provided, it defaults to `MOI.FEASIBLE_POINT` if constraint duals are provided and `MOI.NO_SOLUTION` otherwise. * `constraint_duals`: the remaining positional arguments are passed as pairs. diff --git a/src/Utilities/model.jl b/src/Utilities/model.jl index f7b7882eb2..822cbe73c3 100644 --- a/src/Utilities/model.jl +++ b/src/Utilities/model.jl @@ -30,7 +30,7 @@ mutable struct GenericModel{T,O,V,C} <: AbstractModelLike{T} con_to_name::Dict{MOI.ConstraintIndex,String} name_to_con::Union{Dict{String,MOI.ConstraintIndex},Nothing} # A useful dictionary for extensions to store things. These are - # _not_ copied between models! + # _not_ copied between models. ext::Dict{Symbol,Any} function GenericModel{T,O,V,C}() where {T,O,V,C} return new{T,O,V,C}( @@ -73,7 +73,7 @@ mutable struct GenericOptimizer{T,O,V,C} <: AbstractOptimizer{T} con_to_name::Dict{MOI.ConstraintIndex,String} name_to_con::Union{Dict{String,MOI.ConstraintIndex},Nothing} # A useful dictionary for extensions to store things. These are - # _not_ copied between models! + # _not_ copied between models. ext::Dict{Symbol,Any} function GenericOptimizer{T,O,V,C}() where {T,O,V,C} return new{T,O,V,C}( diff --git a/src/Utilities/parser.jl b/src/Utilities/parser.jl index 8b030be9ce..0ec3f5aa96 100644 --- a/src/Utilities/parser.jl +++ b/src/Utilities/parser.jl @@ -328,11 +328,10 @@ end A utility function to aid writing tests. !!! warning - -This function is not intended for widespread use! It is mainly used as a tool to -simplify writing tests in MathOptInterface. Do not use it as an exchange format -for storing or transmitting problem instances. Use the FileFormats submodule -instead. + This function is not intended for widespread use. It is mainly used as a + tool to simplify writing tests in MathOptInterface. Do not use it as an + exchange format for storing or transmitting problem instances. Use the + FileFormats submodule instead. ## Example diff --git a/src/Utilities/print.jl b/src/Utilities/print.jl index d8132e52bb..0a8f8b2558 100644 --- a/src/Utilities/print.jl +++ b/src/Utilities/print.jl @@ -202,7 +202,7 @@ function _to_string( name_1 = _to_string(options, model, term.variable_1) name_2 = _to_string(options, model, term.variable_2) # Be careful here when printing the coefficient. ScalarQuadraticFunction - # assumes an additional 0.5 factor! + # assumes an additional 0.5 factor. coef = term.coefficient name = if term.variable_1 == term.variable_2 coef /= 2 @@ -415,7 +415,7 @@ end A type used to work-around the default printing of Julia expressions. -Without this type, if we subsititued the variable names into the expression +Without this type, if we substituted the variable names into the expression and then converted to a string, each variable would be printed with enclosing `"`. diff --git a/src/Utilities/results.jl b/src/Utilities/results.jl index 02e019703a..1dd2b15a45 100644 --- a/src/Utilities/results.jl +++ b/src/Utilities/results.jl @@ -30,7 +30,7 @@ function get_fallback(model::MOI.ModelLike, attr::MOI.ObjectiveValue) return MOI.get(model, MOI.VariablePrimal(attr.result_index), vi) end if is_ray(MOI.get(model, MOI.PrimalStatus())) - # Dual infeasibiltiy certificates do not include the primal objective + # Dual infeasibility certificates do not include the primal objective # constant. obj -= MOI.constant(f, typeof(obj)) end @@ -423,7 +423,7 @@ function variable_dual( if !ray sense = MOI.get(model, MOI.ObjectiveSense()) # Dual definition for maximization problem corresponds to dual - # definition for minimization problem with flipped objectived in MOI + # definition for minimization problem with flipped objective in MOI sign = sense == MOI.MAX_SENSE ? -1.0 : 1.0 F = MOI.get(model, MOI.ObjectiveFunctionType()) obj_attr = MOI.ObjectiveFunction{F}() diff --git a/src/Utilities/sets.jl b/src/Utilities/sets.jl index 8d90e27b95..2dcc639a5f 100644 --- a/src/Utilities/sets.jl +++ b/src/Utilities/sets.jl @@ -10,7 +10,7 @@ Returns a new scalar set `new_set` such that `func`-in-`set` is equivalent to `func + offset`-in-`new_set`. -Only define this function if it makes sense to! +Only define this function if it makes sense to. Use [`supports_shift_constant`](@ref) to check if the set supports shifting: ```Julia diff --git a/src/attributes.jl b/src/attributes.jl index 592291fd1e..4bd8d74acb 100644 --- a/src/attributes.jl +++ b/src/attributes.jl @@ -44,7 +44,7 @@ attributes (properties) of constraints in the model. abstract type AbstractConstraintAttribute end # Attributes should not contain any `VariableIndex` or `ConstraintIndex` as the -# set is passed unmodifed during `copy_to`. +# set is passed unmodified during `copy_to`. const AnyAttribute = Union{ AbstractOptimizerAttribute, AbstractModelAttribute, @@ -270,7 +270,7 @@ circumstances, it should still return `true`. Note that `supports` is only defined for attributes for which [`is_copyable`](@ref) returns `true` as other attributes do not appear in the -list of attributes set obtained by `ListOf...AttributesSet`. +list of attributes set obtained by `ListOfXXXAttributesSet`. """ function supports(model::ModelLike, attr::AnyAttribute, args...) return supports_fallback(model, attr, args...) @@ -842,7 +842,7 @@ attribute_value_type(::Silent) = Bool """ TimeLimitSec() -An optimizer attribute for setting a time limit (in seconnds) for an +An optimizer attribute for setting a time limit (in seconds) for an optimization. When `set` to `nothing`, it deactivates the solver time limit. The default value is `nothing`. """ @@ -1402,7 +1402,7 @@ search for the first result. If a (local) optimal solution is available, that is, [`TerminationStatus`](@ref) is `OPTIMAL` or `LOCALLY_SOLVED`, the first result must correspond to the (locally) optimal solution. Other results may be alternative optimal solutions, or they -may be other suboptimal solutions; use [`ObjectiveValue`](@ref) to distingiush +may be other suboptimal solutions; use [`ObjectiveValue`](@ref) to distinguish between them. If a primal or dual infeasibility certificate is available, that is, @@ -1705,7 +1705,7 @@ A constraint attribute for the assignment to some constraint's primal value in result `result_index`. If the constraint is `f(x) in S`, then in most cases the `ConstraintPrimal` is -the value of `f`, evaluated at the correspondng [`VariablePrimal`](@ref) +the value of `f`, evaluated at the corresponding [`VariablePrimal`](@ref) solution. However, some conic solvers reformulate `b - Ax in S` to `s = b - Ax, s in S`. @@ -2260,7 +2260,7 @@ Return a `Bool` indicating whether the value of the attribute is set during an [`optimize!`](@ref) call, that is, the attribute is used to query the result of the optimization. -If an attibute can be set by the user, define [`is_copyable`](@ref) instead. +If an attribute can be set by the user, define [`is_copyable`](@ref) instead. An attribute cannot be both [`is_copyable`](@ref) and `is_set_by_optimize`. @@ -2313,7 +2313,7 @@ during [`copy_to`](@ref) using [`set`](@ref). If an attribute `is_copyable`, then it cannot be modified by the optimizer, and [`get`](@ref) must always return the value that was [`set`](@ref) by the user. -If an attibute is the result of an optimization, define +If an attribute is the result of an optimization, define [`is_set_by_optimize`](@ref) instead. An attribute cannot be both [`is_set_by_optimize`](@ref) and `is_copyable`. diff --git a/src/constraints.jl b/src/constraints.jl index 61d36b8656..9cee1cbcfa 100644 --- a/src/constraints.jl +++ b/src/constraints.jl @@ -135,7 +135,7 @@ Add the constraint ``v \\in \\mathcal{S}`` where ``v`` is the variable (or vecto * An [`UnsupportedConstraint`](@ref) error is thrown if `model` does not support `F`-in-`S` constraints, * a [`AddConstraintNotAllowed`](@ref) error is thrown if it supports `F`-in-`S` - constraints but it cannot add the constraint(s) in its current state and + constraints but it cannot add the constraint in its current state and * a [`ScalarFunctionConstantNotZero`](@ref) error may be thrown if `func` is an `AbstractScalarFunction` with nonzero constant and `set` is [`EqualTo`](@ref), [`GreaterThan`](@ref), [`LessThan`](@ref) or diff --git a/src/sets.jl b/src/sets.jl index 60cab27854..a3aa68f111 100644 --- a/src/sets.jl +++ b/src/sets.jl @@ -2429,7 +2429,7 @@ end CountGreaterThan(dimension::Int) The set ``\\{(c, y, x) \\in \\mathbb{Z}^{1+1+d}\\}``, such that `c` is strictly -greater than the number of occurances of `y` in `x` and `dimension = 1 + 1 + d`. +greater than the number of occurences of `y` in `x` and `dimension = 1 + 1 + d`. ## Also known as @@ -2774,7 +2774,7 @@ function Base.:(==)(x::Reified{S}, y::Reified{S}) where {S} return x.set == y.set end -# TODO(odow): these are not necessarily isbits! They may not be safe to return +# TODO(odow): these are not necessarily isbits. They may not be safe to return # without copying if the number is BigFloat, for example. function Base.copy( set::Union{ diff --git a/test/Bridges/Constraint/quad_to_soc.jl b/test/Bridges/Constraint/quad_to_soc.jl index cfe7e782e8..0c460cf9cf 100644 --- a/test/Bridges/Constraint/quad_to_soc.jl +++ b/test/Bridges/Constraint/quad_to_soc.jl @@ -92,7 +92,7 @@ function test_quadratic_constraints_with_2_variables() # The matrix is # 2 1 # 1 2 - # for which the cholesky factorization is U' * U with U = + # for which the Cholesky factorization is U' * U with U = # √2 √2/2 # . √3/√2 expected = MOI.VectorAffineFunction{Float64}( @@ -187,7 +187,7 @@ function test_fill_reducing_permutation() }(), ) F = LinearAlgebra.cholesky(Q) - # Test that the sparse cholesky pivot is permuted + # Test that the sparse Cholesky pivot is permuted SF = LinearAlgebra.cholesky(SparseArrays.sparse(Q)) @test SF.p == [3, 2, 1] U = Matrix(F.U) diff --git a/test/Bridges/bridge_optimizer.jl b/test/Bridges/bridge_optimizer.jl index 3b1548a018..9493f4c0e4 100644 --- a/test/Bridges/bridge_optimizer.jl +++ b/test/Bridges/bridge_optimizer.jl @@ -1168,9 +1168,9 @@ function test_ListOfVariablesWithAttributeSet(T = Float64) @test MOI.get(model, attr) == x # Handled by UniversalFallback attr = MOI.ListOfVariablesWithAttributeSet(MOI.VariablePrimalStart()) - # ... no attributes set + # no attributes set @test MOI.get(model, attr) == MOI.VariableIndex[] - # ... one attribute set + # one attribute set MOI.set(model, MOI.VariablePrimalStart(), x[2], 1.0) @test MOI.get(model, attr) == [x[2]] return diff --git a/test/FileFormats/LP/LP.jl b/test/FileFormats/LP/LP.jl index 620117ee43..476738dee5 100644 --- a/test/FileFormats/LP/LP.jl +++ b/test/FileFormats/LP/LP.jl @@ -511,7 +511,6 @@ function test_read_model2() @test (MOI.VariableIndex, MOI.Interval{Float64}) in constraints @test (MOI.VariableIndex, MOI.Integer) in constraints @test (MOI.VariableIndex, MOI.ZeroOne) in constraints - # Adicionar testes dos bounds de V8 @test MOI.get(model, MOI.VariableName(), MOI.VariableIndex(8)) == "V8" @test model.variables.lower[8] == -Inf @test model.variables.upper[8] == -3 diff --git a/test/Nonlinear/ReverseAD.jl b/test/Nonlinear/ReverseAD.jl index 71302cc844..014d6e96a2 100644 --- a/test/Nonlinear/ReverseAD.jl +++ b/test/Nonlinear/ReverseAD.jl @@ -309,7 +309,7 @@ function test_constraint_quadratic_multivariate_subexpressions() MOI.eval_constraint_jacobian_transpose_product(evaluator, y, x_val, w) wJ = w' * [(2 * x_val[1] + x_val[2]) (x_val[1] + 2 * x_val[2])] @test y ≈ wJ[:] - # Hessian-lagrangian + # Hessian-Lagrangian @test MOI.hessian_lagrangian_structure(evaluator) == [(1, 1), (2, 2), (2, 1)] H = [NaN, NaN, NaN] @@ -390,7 +390,7 @@ function test_hessian_registered_error() end function ∇²f(H, x...) H[1, 1] = 1200 * x[1]^2 - 400 * x[2] + 2 - # Wrong index! Should be [2, 1] + # Wrong index. Should be [2, 1] H[1, 2] = -400 * x[1] H[2, 2] = 200.0 return diff --git a/test/Utilities/cachingoptimizer.jl b/test/Utilities/cachingoptimizer.jl index cb8283bf4d..6113ffbf33 100644 --- a/test/Utilities/cachingoptimizer.jl +++ b/test/Utilities/cachingoptimizer.jl @@ -129,11 +129,11 @@ function test_MOI_Test() end # !!! warning -# This is some type piracy! To enable CachingOptimizer to pass some MOI.Test +# This is some type piracy. To enable CachingOptimizer to pass some MOI.Test # functions with MockOptimizer, we overload `setup_test` to setup the inner # mock optimizer. # -# This is pretty fragile! It requires the inner optimizer to be attached, +# This is pretty fragile. It requires the inner optimizer to be attached, # amongst other things. It's used by `test_compute_conflict` below, but not # by test_MOI_Test above (test_MOI_Test has `exclude = Any[MOI.optimize!]`). function MOI.Test.setup_test( diff --git a/test/Utilities/print.jl b/test/Utilities/print.jl index 4358283f3b..d765f88b39 100644 --- a/test/Utilities/print.jl +++ b/test/Utilities/print.jl @@ -26,7 +26,7 @@ const LATEX = MIME("text/latex") const PLAIN = MIME("text/plain") const IN = Sys.iswindows() ? "in" : "∈" -# Windows fun... +# Windows fun function _string_compare(a, b) @test replace(a, "\r\n" => "\n") == replace(b, "\r\n" => "\n") return diff --git a/test/Utilities/universalfallback.jl b/test/Utilities/universalfallback.jl index ebbc5bacf8..af541629a0 100644 --- a/test/Utilities/universalfallback.jl +++ b/test/Utilities/universalfallback.jl @@ -76,7 +76,7 @@ function test_MOI_Test() MOI.Test.Config(exclude = Any[MOI.optimize!]), exclude = String[ # UniversalFallback fails all these tests because it supports - # everything... + # everything "test_attribute_", "test_model_supports_constraint_", "test_model_copy_to_Unsupported", @@ -164,7 +164,7 @@ function test_model_attributes() MOI.Test.UnknownModelAttribute(), MOI.ListOfModelAttributesSet(), ) - # Test that emptying the uf get's rid of the model attributes! + # Test that emptying the uf get's rid of the model attributes @test !MOI.is_empty(uf) MOI.empty!(uf) @test MOI.is_empty(uf) @@ -462,9 +462,9 @@ function test_ListOfVariablesWithAttributeSet() @test MOI.get(model, attr) == x # Handled by UniversalFallback attr = MOI.ListOfVariablesWithAttributeSet(MOI.VariablePrimalStart()) - # ... no attributes set + # no attributes set @test MOI.get(model, attr) == MOI.VariableIndex[] - # ... one attribute set + # one attribute set MOI.set(model, MOI.VariablePrimalStart(), x[2], 1.0) @test MOI.get(model, attr) == [x[2]] return @@ -482,9 +482,9 @@ function test_ListOfConstraintsWithAttributeSet() # Handled by UniversalFallback attr = MOI.ListOfConstraintsWithAttributeSet{F,S}(MOI.ConstraintPrimalStart()) - # ... no attributes set + # no attributes set @test MOI.get(model, attr) == MOI.ConstraintIndex{F,S}[] - # ... one attribute set + # one attribute set MOI.set(model, MOI.ConstraintPrimalStart(), c[2], 1.0) @test MOI.get(model, attr) == [c[2]] return