11using Test
22
33"""
4- evalvariables (varval::Function, f::AbstractFunction)
4+ eval_variables (varval::Function, f::AbstractFunction)
55
66Returns the value of function `f` if each variable index `vi` is evaluated as `varval(vi)`.
77"""
8- function evalvariables end
9- evalvariables (varval:: Function , f:: SVF ) = varval (f. variable)
10- evalvariables (varval:: Function , f:: VVF ) = varval .(f. variables)
11- function evalvariables (varval:: Function , f:: SAF )
8+ function eval_variables end
9+ eval_variables (varval:: Function , f:: SVF ) = varval (f. variable)
10+ eval_variables (varval:: Function , f:: VVF ) = varval .(f. variables)
11+ function eval_variables (varval:: Function , f:: SAF )
1212 return mapreduce (t-> evalterm (varval, t), + , f. terms, init= f. constant)
1313end
14- function evalvariables (varval:: Function , f:: VAF )
14+ function eval_variables (varval:: Function , f:: VAF )
1515 out = copy (f. constants)
1616 for t in f. terms
1717 out[t. output_index] += evalterm (varval, t. scalar_term)
1818 end
1919 out
2020end
21- function evalvariables (varval:: Function , f:: SQF )
21+ function eval_variables (varval:: Function , f:: SQF )
2222 init = zero (f. constant)
2323 lin = mapreduce (t-> evalterm (varval, t), + , f. affine_terms, init= init)
2424 quad = mapreduce (t-> evalterm (varval, t), + , f. quadratic_terms, init= init)
2525 return lin + quad + f. constant
2626end
27- function evalvariables (varval:: Function , f:: VQF )
27+ function eval_variables (varval:: Function , f:: VQF )
2828 out = copy (f. constants)
2929 for t in f. affine_terms
3030 out[t. output_index] += evalterm (varval, t. scalar_term)
@@ -204,13 +204,13 @@ function unsafe_add(t1::VT, t2::VT) where VT <: Union{MOI.VectorAffineTerm,
204204end
205205
206206"""
207- iscanonical (f::Union{ScalarAffineFunction, ScalarQuadraticFunction
207+ is_canonical (f::Union{ScalarAffineFunction, ScalarQuadraticFunction
208208 VectorAffineFunction, VectorQuadraticTerm})
209209
210210Returns a Bool indicating whether the function is in canonical form.
211211See [`canonical`](@ref).
212212"""
213- function iscanonical (f:: Union{SAF, VAF, SQF, VQF} )
213+ function is_canonical (f:: Union{SAF, VAF, SQF, VQF} )
214214 is_strictly_sorted (f. terms, MOI. term_indices,
215215 t -> ! iszero (MOI. coefficient (t)))
216216end
@@ -460,44 +460,44 @@ function _rmvar(vis_or_terms::Vector, vi)
460460end
461461
462462"""
463- removevariable (f::AbstractFunction, vi::VariableIndex)
463+ remove_variable (f::AbstractFunction, vi::VariableIndex)
464464
465465Return a new function `f` with the variable vi removed.
466466"""
467- function removevariable end
468- function removevariable (f:: MOI.SingleVariable , vi:: MOI.VariableIndex )
467+ function remove_variable end
468+ function remove_variable (f:: MOI.SingleVariable , vi:: MOI.VariableIndex )
469469 if f. variable == vi
470470 error (" Cannot remove variable from a `SingleVariable` function of the" ,
471471 " same variable." )
472472 end
473473 return f
474474end
475- function removevariable (f:: VVF , vi)
475+ function remove_variable (f:: VVF , vi)
476476 VVF (_rmvar (f. variables, vi))
477477end
478- function removevariable (f:: Union{SAF, VAF} , vi)
478+ function remove_variable (f:: Union{SAF, VAF} , vi)
479479 typeof (f)(_rmvar (f. terms, vi), MOI. constant (f))
480480end
481- function removevariable (f:: Union{SQF, VQF} , vi)
481+ function remove_variable (f:: Union{SQF, VQF} , vi)
482482 terms = _rmvar .((f. affine_terms, f. quadratic_terms), Ref (vi))
483483 typeof (f)(terms... , MOI. constant (f))
484484end
485485
486486"""
487- modifyfunction (f::AbstractFunction, change::AbstractFunctionModification)
487+ modify_function (f::AbstractFunction, change::AbstractFunctionModification)
488488
489489Return a new function `f` modified according to `change`.
490490"""
491- function modifyfunction (f:: SAF , change:: MOI.ScalarConstantChange )
491+ function modify_function (f:: SAF , change:: MOI.ScalarConstantChange )
492492 return SAF (f. terms, change. new_constant)
493493end
494- function modifyfunction (f:: VAF , change:: MOI.VectorConstantChange )
494+ function modify_function (f:: VAF , change:: MOI.VectorConstantChange )
495495 return VAF (f. terms, change. new_constant)
496496end
497- function modifyfunction (f:: SQF , change:: MOI.ScalarConstantChange )
497+ function modify_function (f:: SQF , change:: MOI.ScalarConstantChange )
498498 return SQF (f. affine_terms, f. quadratic_terms, change. new_constant)
499499end
500- function modifyfunction (f:: VQF , change:: MOI.VectorConstantChange )
500+ function modify_function (f:: VQF , change:: MOI.VectorConstantChange )
501501 return VQF (f. affine_terms, f. quadratic_terms, change. new_constant)
502502end
503503function _modifycoefficient (terms:: Vector{<:MOI.ScalarAffineTerm} , variable:: VI , new_coefficient)
@@ -518,11 +518,11 @@ function _modifycoefficient(terms::Vector{<:MOI.ScalarAffineTerm}, variable::VI,
518518 end
519519 terms
520520end
521- function modifyfunction (f:: SAF , change:: MOI.ScalarCoefficientChange )
521+ function modify_function (f:: SAF , change:: MOI.ScalarCoefficientChange )
522522 lin = _modifycoefficient (f. terms, change. variable, change. new_coefficient)
523523 return SAF (lin, f. constant)
524524end
525- function modifyfunction (f:: SQF , change:: MOI.ScalarCoefficientChange )
525+ function modify_function (f:: SQF , change:: MOI.ScalarCoefficientChange )
526526 lin = _modifycoefficient (f. affine_terms, change. variable, change. new_coefficient)
527527 return SQF (lin, f. quadratic_terms, f. constant)
528528end
@@ -553,13 +553,13 @@ function _modifycoefficients(n, terms::Vector{<:MOI.VectorAffineTerm}, variable:
553553 end
554554 terms
555555end
556- function modifyfunction (f:: VAF , change:: MOI.MultirowChange )
556+ function modify_function (f:: VAF , change:: MOI.MultirowChange )
557557 dim = MOI. output_dimension (f)
558558 coefficients = change. new_coefficients
559559 lin = _modifycoefficients (dim, f. terms, change. variable, coefficients)
560560 VAF (lin, f. constants)
561561end
562- function modifyfunction (f:: VQF , change:: MOI.MultirowChange )
562+ function modify_function (f:: VQF , change:: MOI.MultirowChange )
563563 dim = MOI. output_dimension (f)
564564 coefficients = change. new_coefficients
565565 lin = _modifycoefficients (dim, f. affine_terms, change. variable, coefficients)
0 commit comments