1

I was wondering if there is a best practices to calculating variables, or more specifically, adding constraints to an optimization model using derivatives of variables.

To provide a concrete example. I have a function let's call output which I know is a non-linear combination of inputs.

ln Q = sum(phi_i ln(X_i) for i in n) 

However, I know that there is a budget constraint. And using this I can use the Lagragian to get some information about the change in Q and inputs. More specifically I know.

d(X_i)/X_i = d(Q)/Q - sum(eta * phi_j * (P_i - P_j) for j in n if j != i) 

equivalently

d(ln(X_i)) = d(ln(Q)) - sum(eta * phi_j * (P_i - P_j) for j in n if j != i) 

Entering the constraints into the JuMP optimization problem is a bit confusing if I don't have a way of calculating Q from d(Q). I suppose I could create a new equation that would be

Q_new = Q_prev + d(Q)

However, when running this model in "near" continuous time, I would have to set up lags where Q_prev was the Q from the previous optimized model. I have seen other modeling languages incorporate d(variable) into the constraints, and I'm wondering if JuMP has an elegant way of doing this.

Adam
  • 313
  • 1
  • 3
  • 11

1 Answers1

1

I'm not sure I fully understand your question, but the short answer is probably "no, JuMP doesn't have an elegant way of using the derivative of a variable in a constraint."

If you're doing some sort of trajectory optimization, you might want to take a look at

You might also want to take a look at these tutorials:

using derivatives of variables

The derivative of a variable with respect to what?

JuMP is a library for constrained mathematical optimization. What are the decision variables? What are the constraints? What is the objective?

I have seen other modeling languages incorporate d(variable) into the constraints

Which ones? Do you have examples?

p.s. since this isn't a question with a nice concrete answer, this question might be better suited to our community forum: https://discourse.julialang.org/c/domain/opt/13

Oscar Dowson
  • 2,395
  • 1
  • 5
  • 13
  • I appreciate the response, thank you, you're right I did not specify the what derivative. The example I was looking at was `.mdl` file which apparently is something called MoDeL language. One of the constraints was: `d(log(F_n[f, s])) = d(log(Y[s])) - d(log(PROG[f, s])) + d(SUBST_F[f, s])`. Extremely bizarre syntax I thought. I suppose perhaps in discrete steps its really delta or change in X = change in Y - change in PROG + change in SUBST. – Adam Aug 08 '23 at 03:01
  • Perhaps you're correct, this is more of an open-ended exploratory question, not the best for this forum – Adam Aug 08 '23 at 03:04
  • 1
    I still don't know what the derivative is respect to. s? The only variable in each term? In which case, isn't this just `1 / F_n[f, s] = 1 / Y[s] - 1 / PROG[f, s] + 1`? Happy to talk more on the forum, it's much easier than the SO comment section :) – Oscar Dowson Aug 08 '23 at 05:27