@@ -27,7 +27,9 @@ julia> @infinite_parameter(model, t in [0, 10],
2727
2828julia> @infinite_parameter(model, ξ ~ Uniform(-1, 1));
2929
30- julia> @variable(model, y, Infinite(t, ξ));
30+ julia> @infinite_parameter(model, x in [-1, 1]);
31+
32+ julia> @variable(model, y, Infinite(t, x, ξ));
3133
3234julia> @variable(model, q, Infinite(t));
3335```
@@ -45,24 +47,28 @@ scenes all the appropriate calculus will be applied, creating derivative variabl
4547as needed. For example, we can define the following:
4648``` jldoctest deriv_basic
4749julia> d1 = deriv(y, t)
48- ∂/∂t[y(t, ξ)]
50+ ∂/∂t[y(t, x, ξ)]
4951
50- julia> d2 = ∂(y, t, ξ )
51- ∂/∂ξ [∂/∂t[y(t, ξ)]]
52+ julia> d2 = ∂(y, t, x )
53+ ∂/∂x [∂/∂t[y(t, x , ξ)]]
5254
5355julia> d3 = @∂(q, t^2) # the macro version allows the `t^2` syntax
5456d²/dt²[q(t)]
5557
5658julia> d_expr = deriv(y * q - 2t, t)
57- ∂/∂t[y(t, ξ)]*q(t) + d/dt[q(t)]*y(t, ξ) - 2
59+ ∂/∂t[y(t, x, ξ)]*q(t) + d/dt[q(t)]*y(t, x , ξ) - 2
5860```
5961Thus, we can define derivatives in a variety of forms according to the problem at
60- hand. The last example even shows how the product rule is correctly applied.
62+ hand. The last example even shows how the product rule is correctly applied.
6163
6264!!! note
6365 For convenience in making more compact code we provide [ ` ∂ ` ] ( @ref )
6466 as an alias for [ ` deriv ` ] ( @ref ) .
6567
68+ !!! note
69+ Derivatives taken with respect to dependent infinite parameters are not
70+ supported.
71+
6672Also, notice that the appropriate symbolic calculus is applied to infinite
6773parameters. For example, we could also compute:
6874``` jldoctest deriv_basic
@@ -170,7 +176,7 @@ More detailed information on `JuMP.VariableInfo` is provided in the
170176Now that we have our variable information we can make a derivative using
171177[ ` build_derivative ` ] ( @ref ) :
172178``` jldoctest deriv_basic
173- julia> d = build_derivative(error, info, y, ξ , 1);
179+ julia> d = build_derivative(error, info, y, x , 1);
174180
175181julia> d isa Derivative
176182true
@@ -184,14 +190,14 @@ will add the [`Derivative`](@ref) object and return `GeneralVariableRef` pointin
184190to it that we can use in ` InfiniteOpt ` expressions:
185191``` jldoctest deriv_basic
186192julia> dref = add_derivative(model, d)
187- ∂/∂ξ [y(t, ξ)]
193+ ∂/∂x [y(t, x , ξ)]
188194```
189195This will also create any appropriate information based constraints (e.g., lower
190196bounds).
191197
192198Finally, we note that higher order derivatives by changing the order argument:
193199``` jldoctest deriv_basic
194- julia> d = build_derivative(error, info, y, ξ , 3); # 3rd order derivative
200+ julia> d = build_derivative(error, info, y, x , 3); # 3rd order derivative
195201```
196202
197203### Macro Definition
@@ -208,7 +214,7 @@ of 1 with an initial guess of 0 and assign it to an alias
208214` GeneralVariableRef ` called ` dydt2 ` :
209215``` jldoctest deriv_basic
210216julia> @variable(model, dydt2 >= 1, Deriv(y, t, 2), start = 0)
211- dydt2(t, ξ)
217+ dydt2(t, x, ξ)
212218```
213219This will also support anonymous definition and multi-dimensional definition.
214220Please see [ Macro Variable Definition] ( @ref ) for more information.
@@ -228,17 +234,17 @@ derivative definition, handling the nesting as appropriate. For example, we can
228234"define" `` \frac{\partial^2 y(t, \xi)}{\partial t^2} `` again:
229235``` jldoctest deriv_basic
230236julia> @deriv(d1, t) # recall `d1 = deriv(y, t)`
231- dydt2(t, ξ)
237+ dydt2(t, x, ξ)
232238
233239julia> @deriv(y, t^2)
234- dydt2(t, ξ)
240+ dydt2(t, x, ξ)
235241```
236242Notice that the derivative references all point to the same derivative object we
237243defined up above with its alias name ` dydt2 ` . This macro can also tackle complex
238244expressions using the appropriate calculus such as:
239245``` jldoctest deriv_basic
240246julia> @deriv(∫(y, ξ) * q, t)
241- d/dt[∫{ξ ∈ [-1, 1]}[y(t, ξ)]]*q(t) + d/dt[q(t)]*∫{ξ ∈ [-1, 1]}[y(t, ξ)]
247+ d/dt[∫{ξ ∈ [-1, 1]}[y(t, x, ξ)]]*q(t) + d/dt[q(t)]*∫{ξ ∈ [-1, 1]}[y(t, x , ξ)]
242248```
243249Thus, demonstrating the convenience of using ` @deriv ` .
244250
@@ -457,18 +463,18 @@ We can build these relations for a particular derivative via [`evaluate`](@ref).
457463For example, let's build evaluation equations for ` d1 ` :
458464``` jldoctest deriv_basic
459465julia> d1
460- ∂/∂t[y(t, ξ)]
466+ ∂/∂t[y(t, x, ξ)]
461467
462468julia> fill_in_supports!(t, num_supports = 5) # add supports first
463469
464470julia> evaluate(d1)
465471
466472julia> derivative_constraints(d1)
4674734-element Vector{InfOptConstraintRef}:
468- 2.5 ∂/∂t[y(t, ξ)](0, ξ) + y(0, ξ) - y(2.5, ξ) = 0, ∀ ξ ~ Uniform
469- 2.5 ∂/∂t[y(t, ξ)](2.5, ξ) + y(2.5, ξ) - y(5, ξ) = 0, ∀ ξ ~ Uniform
470- 2.5 ∂/∂t[y(t, ξ)](5, ξ) + y(5, ξ) - y(7.5, ξ) = 0, ∀ ξ ~ Uniform
471- 2.5 ∂/∂t[y(t, ξ)](7.5, ξ) + y(7.5, ξ) - y(10, ξ) = 0, ∀ ξ ~ Uniform
474+ 2.5 ∂/∂t[y(t, x, ξ)](0, x, ξ) + y(0, x, ξ) - y(2.5, x, ξ) = 0, ∀ ξ ~ Uniform, x ∈ [-1, 1]
475+ 2.5 ∂/∂t[y(t, x, ξ)](2.5, x, ξ) + y(2.5, x, ξ) - y(5, x, ξ) = 0, ∀ ξ ~ Uniform, x ∈ [-1, 1]
476+ 2.5 ∂/∂t[y(t, x, ξ)](5, x, ξ) + y(5, x, ξ) - y(7.5, x, ξ) = 0, ∀ ξ ~ Uniform, x ∈ [-1, 1]
477+ 2.5 ∂/∂t[y(t, x, ξ)](7.5, x, ξ) + y(7.5, x, ξ) - y(10, x, ξ) = 0, ∀ ξ ~ Uniform, x ∈ [-1, 1]
472478```
473479Note that we made sure ` t ` had supports first over which we could carry out the
474480evaluation, otherwise an error would have been thrown. Moreover, once the
@@ -478,15 +484,15 @@ evaluation was completed we were able to access the auxiliary equations via
478484We can also, add the necessary auxiliary equations for all the derivatives in the
479485model if we call [ ` evaluate_all_derivatives! ` ] ( @ref ) :
480486``` jldoctest deriv_basic
481- julia> fill_in_supports!(ξ , num_supports = 4) # add supports first
487+ julia> fill_in_supports!(x , num_supports = 4) # add supports first
482488
483489julia> evaluate_all_derivatives!(model)
484490
485491julia> derivative_constraints(dydt2)
4864923-element Vector{InfOptConstraintRef}:
487- 6.25 dydt2(0, ξ) - y(0, ξ) + 2 y(2.5, ξ) - y(5, ξ) = 0, ∀ ξ ~ Uniform
488- 6.25 dydt2(2.5, ξ) - y(2.5, ξ) + 2 y(5, ξ) - y(7.5, ξ) = 0, ∀ ξ ~ Uniform
489- 6.25 dydt2(5, ξ) - y(5, ξ) + 2 y(7.5, ξ) - y(10, ξ) = 0, ∀ ξ ~ Uniform
493+ 6.25 dydt2(0, x, ξ) - y(0, x, ξ) + 2 y(2.5, x, ξ) - y(5, x, ξ) = 0, ∀ ξ ~ Uniform, x ∈ [-1, 1]
494+ 6.25 dydt2(2.5, x, ξ) - y(2.5, x, ξ) + 2 y(5, x, ξ) - y(7.5, x, ξ) = 0, ∀ ξ ~ Uniform, x ∈ [-1, 1]
495+ 6.25 dydt2(5, x, ξ) - y(5, x, ξ) + 2 y(7.5, x, ξ) - y(10, x, ξ) = 0, ∀ ξ ~ Uniform, x ∈ [-1, 1]
490496```
491497
492498Finally, we note that once derivative constraints have been added to the
@@ -496,10 +502,10 @@ and a warning will be thrown to indicate such:
496502``` jldoctest deriv_basic
497503julia> derivative_constraints(d1)
4985044-element Vector{InfOptConstraintRef}:
499- 2.5 ∂/∂t[y(t, ξ)](0, ξ) + y(0, ξ) - y(2.5, ξ) = 0, ∀ ξ ~ Uniform
500- 2.5 ∂/∂t[y(t, ξ)](2.5, ξ) + y(2.5, ξ) - y(5, ξ) = 0, ∀ ξ ~ Uniform
501- 2.5 ∂/∂t[y(t, ξ)](5, ξ) + y(5, ξ) - y(7.5, ξ) = 0, ∀ ξ ~ Uniform
502- 2.5 ∂/∂t[y(t, ξ)](7.5, ξ) + y(7.5, ξ) - y(10, ξ) = 0, ∀ ξ ~ Uniform
505+ 2.5 ∂/∂t[y(t, x, ξ)](0, x, ξ) + y(0, x, ξ) - y(2.5, x, ξ) = 0, ∀ ξ ~ Uniform, x ∈ [-1, 1]
506+ 2.5 ∂/∂t[y(t, x, ξ)](2.5, x, ξ) + y(2.5, x, ξ) - y(5, x, ξ) = 0, ∀ ξ ~ Uniform, x ∈ [-1, 1]
507+ 2.5 ∂/∂t[y(t, x, ξ)](5, x, ξ) + y(5, x, ξ) - y(7.5, x, ξ) = 0, ∀ ξ ~ Uniform, x ∈ [-1, 1]
508+ 2.5 ∂/∂t[y(t, x, ξ)](7.5, x, ξ) + y(7.5, x, ξ) - y(10, x, ξ) = 0, ∀ ξ ~ Uniform, x ∈ [-1, 1]
503509
504510julia> add_supports(t, 0.2)
505511┌ Warning: Support/method changes will invalidate existing derivative evaluation constraints that have been added to the InfiniteModel. Thus, these are being deleted.
@@ -519,7 +525,7 @@ First, let's overview the basic object inquiries: [`derivative_argument`](@ref),
519525[ ` derivative_method ` ] ( @ref ) , and [ ` name ` ] (@ref JuMP.name(::DecisionVariableRef)):
520526``` jldoctest deriv_basic
521527julia> derivative_argument(dydt2) # get the variable the derivative operates on
522- y(t, ξ)
528+ y(t, x, ξ)
523529
524530julia> operator_parameter(dydt2) # get the parameter the operator is taken with respect to
525531t
@@ -553,10 +559,10 @@ Also, since derivatives are analogous to infinite variables, they inherit many
553559of the same queries including [ ` parameter_refs ` ] ( @ref ) :
554560``` jldoctest deriv_basic
555561julia> parameter_refs(d1)
556- (t, ξ)
562+ (t, x, ξ)
557563
558564julia> parameter_refs(derivative_argument(d1))
559- (t, ξ)
565+ (t, x, ξ)
560566```
561567Since derivatives simply inherit their infinite parameter dependencies from the
562568argument variable, the above lines are equivalent.
@@ -573,7 +579,7 @@ julia> lower_bound(dydt2)
5735791.0
574580
575581julia> LowerBoundRef(dydt2)
576- dydt2(t, ξ) ≥ 1, ∀ t ∈ [0, 10], ξ ~ Uniform
582+ dydt2(t, x, ξ) ≥ 1, ∀ t ∈ [0, 10], ξ ~ Uniform, x ∈ [-1, 1]
577583
578584julia> has_upper_bound(dydt2)
579585false
@@ -590,13 +596,13 @@ julia> num_derivatives(model)
590596
591597julia> all_derivatives(model)
5925987-element Vector{GeneralVariableRef}:
593- ∂/∂t[y(t, ξ)]
594- ∂/∂ξ [∂/∂t[y(t, ξ)]]
599+ ∂/∂t[y(t, x, ξ)]
600+ ∂/∂x [∂/∂t[y(t, x , ξ)]]
595601 d²/dt²[q(t)]
596602 d/dt[q(t)]
597- ∂/∂ξ [y(t, ξ)]
598- dydt2(t, ξ)
599- d/dt [∫{ξ ∈ [-1, 1]}[y(t, ξ)]]
603+ ∂/∂x [y(t, x , ξ)]
604+ dydt2(t, x, ξ)
605+ ∂/∂t [∫{ξ ∈ [-1, 1]}[y(t, x , ξ)]]
600606```
601607
602608## Modification Methods
@@ -623,7 +629,7 @@ julia> fix(dydt2, 42, force = true)
623629julia> fix_value(dydt2)
62463042.0
625631
626- julia> set_start_value_function(dydt2, (t, xi) -> t + xi)
632+ julia> set_start_value_function(dydt2, (t, x, xi) -> t + x + xi)
627633
628634julia> unfix(dydt2)
629635
0 commit comments