Ref #304, there's still a mismatch between the support for parameters in nonlinear and linear/quadratic problems. Potentially we could store the A matrix in the model explicitly and update coefficients for different parameter values, reusing the same sparsity pattern. I think the main hurdle is building up expressions or constraints where AffExprs and parameters are co-mingled.
Just remembered the reason why we can't do this. Let's say N is a parameter, then you do:
@defVar(m, x[1:N])
@addConstraint(m, sum{x[i],i=1:N} <= 1)
What happens when you change N? It's not just about updating the coefficients in the constraint matrix.
Well we can never have that, but there's still the possibility of supporting "coefficient" parameters.
Can they be used inside of filter conditions?
No, it would only be parameters for variable coefficients or constant terms in affine/quadratic constraints.
@defParam(model, p)
@addConstraint(model, p*x == p^2-1)
By no means as general as the nonlinear parameters, but better than nothing.
The ratio of increased complexity of _everything_ in JuMP to usefulness is pretty high here
Wait, do nonlinear parameters work in sums or filter conditions right now?
No, just inside expressions
So
@addNLConstraint(m, sum{x[i],i=1:N} <= 1)
doesn't work either when N is a parameter?
No, although AFAIK it does in AMPL
+1, would really like to have this feature
This is entirely speculative and out of scope for JuMP 1.0, so I'm tempted to close.
Yeah. I have an application for this, but I don't think the speed improvement gained by poking the constraint matrix over rebuilding the model outweighs the additional complexity in JuMP.
If anyone would like to rewrite JuMP to support this, get in touch. No use keeping the issue open though.
Most helpful comment
If anyone would like to rewrite JuMP to support this, get in touch. No use keeping the issue open though.