Mathematica Asked by VarunM on February 8, 2021
How to supply the gradient information for constraint in FindMinimum?
I have to minimize a function subject to constraints, both of which are computed numerically for each iteration of FindMinimum
. In order to supply the gradient information, the documentation recommends to use Gradient
option. This is very straightforward without the constraint. An example is given below.
f[x_?NumericQ] := x^2 - 28 x;
df[x_?NumericQ] := 2 x - 28 ;
FindMinimum[{f[a]}, {a, 5}, Gradient -> {df[a]}]
The above example fetches the solution from the supplied gradient df
.
But I want to do the same with a constrained minimization problem, for which the constraint gradient also needs to be defined (Interior Point Algorithm). How to achieve this using the Gradient
Option?. The following approach is not successful for me.
Single Variable:
f[x_?NumericQ] := x^2 - 28 x;
cons[x_?NumericQ] := x - 10
df[x_?NumericQ] := 2 x - 28 ;
dcons[x_?NumericQ] := 1;
FindMinimum[{f[a], cons[a] <= 0}, {a, 5},Gradient -> {{df[a]}, {dcons[a]}}]
Two Variable:
f2[x1_?NumericQ, y1_?NumericQ] := x1^2 + y1^2;
cons2[x1_?NumericQ, y1_?NumericQ] := (x1 - 1)^2 + 2 (y1 - 1)^2;
df2[x1_?NumericQ, y1_?NumericQ] := {2 x1, 2 y1};
dcons2[x1_?NumericQ, y1_?NumericQ] := {2 (-1 + x1), 4 (-1 + y1)};
FindMinimum[{f2[a, b], cons2[a, b] > 5}, {a, b},Gradient -> {df2, dcons2}]
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP