11"""
22 struct ModifyConstraintNotAllowed{F<:AbstractFunction, S<:AbstractSet,
3- C<:AbstractFunctionModification} <: NotAllowedError
3+ C<:AbstractFunctionModification} <: NotAllowedError
44 constraint_index::ConstraintIndex{F, S}
55 change::C
66 message::String
@@ -10,15 +10,18 @@ An error indicating that the constraint modification `change` cannot be applied
1010to the constraint of index `ci`.
1111"""
1212struct ModifyConstraintNotAllowed{F<: AbstractFunction , S<: AbstractSet ,
13- C<: AbstractFunctionModification } <: NotAllowedError
13+ C<: AbstractFunctionModification } <: NotAllowedError
1414 constraint_index:: ConstraintIndex{F, S}
1515 change:: C
1616 message:: String
1717end
18- function ModifyConstraintNotAllowed (ci:: ConstraintIndex{F, S} ,
19- change:: AbstractFunctionModification ) where {F<: AbstractFunction , S<: AbstractSet }
20- ModifyConstraintNotAllowed {F, S, typeof(change)} (ci, change, " " )
18+ function ModifyConstraintNotAllowed (
19+ ci:: ConstraintIndex{F, S} ,
20+ change:: AbstractFunctionModification ,
21+ message= " " ) where {F<: AbstractFunction , S<: AbstractSet }
22+ return ModifyConstraintNotAllowed {F, S, typeof(change)} (ci, change, message)
2123end
24+ throw_modify_not_allowed (ci:: ConstraintIndex , args... ) = throw (ModifyConstraintNotAllowed (ci, args... ))
2225
2326operation_name (err:: ModifyConstraintNotAllowed{F, S} ) where {F, S} = " Modifying the constraints $(err. constraint_index) with $(err. change) "
2427
@@ -36,8 +39,9 @@ struct ModifyObjectiveNotAllowed{C<:AbstractFunctionModification} <: NotAllowedE
3639 message:: String
3740end
3841function ModifyObjectiveNotAllowed (change:: AbstractFunctionModification )
39- ModifyObjectiveNotAllowed (change, " " )
42+ return ModifyObjectiveNotAllowed (change, " " )
4043end
44+ throw_modify_not_allowed (:: ObjectiveFunction , args... ) = throw (ModifyObjectiveNotAllowed (args... ))
4145
4246operation_name (err:: ModifyObjectiveNotAllowed ) = " Modifying the objective function with $(err. change) "
4347
@@ -75,12 +79,12 @@ modify(model, ObjectiveFunction{ScalarAffineFunction{Float64}}(), ScalarConstant
7579"""
7680function modify end
7781
78- function modify (model:: ModelLike , ci:: ConstraintIndex{F, S} ,
79- change:: AbstractFunctionModification ) where {F, S}
80- throw ( ModifyConstraintNotAllowed ( ci, change) )
82+ function modify (model:: ModelLike , ci:: ConstraintIndex ,
83+ change:: AbstractFunctionModification )
84+ throw_modify_not_allowed ( ci, change)
8185end
8286
83- function modify (model:: ModelLike , :: ObjectiveFunction ,
84- change:: AbstractFunctionModification )
85- throw ( ModifyObjectiveNotAllowed ( change) )
87+ function modify (model:: ModelLike , attr :: ObjectiveFunction ,
88+ change:: AbstractFunctionModification )
89+ throw_modify_not_allowed (attr, change)
8690end
0 commit comments