1
1
"""
2
2
struct ModifyConstraintNotAllowed{F<:AbstractFunction, S<:AbstractSet,
3
- C<:AbstractFunctionModification} <: NotAllowedError
3
+ C<:AbstractFunctionModification} <: NotAllowedError
4
4
constraint_index::ConstraintIndex{F, S}
5
5
change::C
6
6
message::String
@@ -10,15 +10,18 @@ An error indicating that the constraint modification `change` cannot be applied
10
10
to the constraint of index `ci`.
11
11
"""
12
12
struct ModifyConstraintNotAllowed{F<: AbstractFunction , S<: AbstractSet ,
13
- C<: AbstractFunctionModification } <: NotAllowedError
13
+ C<: AbstractFunctionModification } <: NotAllowedError
14
14
constraint_index:: ConstraintIndex{F, S}
15
15
change:: C
16
16
message:: String
17
17
end
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)
21
23
end
24
+ throw_modify_not_allowed (ci:: ConstraintIndex , args... ) = throw (ModifyConstraintNotAllowed (ci, args... ))
22
25
23
26
operation_name (err:: ModifyConstraintNotAllowed{F, S} ) where {F, S} = " Modifying the constraints $(err. constraint_index) with $(err. change) "
24
27
@@ -36,8 +39,9 @@ struct ModifyObjectiveNotAllowed{C<:AbstractFunctionModification} <: NotAllowedE
36
39
message:: String
37
40
end
38
41
function ModifyObjectiveNotAllowed (change:: AbstractFunctionModification )
39
- ModifyObjectiveNotAllowed (change, " " )
42
+ return ModifyObjectiveNotAllowed (change, " " )
40
43
end
44
+ throw_modify_not_allowed (:: ObjectiveFunction , args... ) = throw (ModifyObjectiveNotAllowed (args... ))
41
45
42
46
operation_name (err:: ModifyObjectiveNotAllowed ) = " Modifying the objective function with $(err. change) "
43
47
@@ -75,12 +79,12 @@ modify(model, ObjectiveFunction{ScalarAffineFunction{Float64}}(), ScalarConstant
75
79
"""
76
80
function modify end
77
81
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)
81
85
end
82
86
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)
86
90
end
0 commit comments