From 236b957bfbce270fbfc1950be3e4cddfa311d1d5 Mon Sep 17 00:00:00 2001 From: Alasdair Gray Date: Wed, 26 Jun 2024 12:16:10 -0400 Subject: [PATCH] Add templates for required parOpt sparse constraint functions --- pyoptsparse/pyParOpt/ParOpt.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/pyoptsparse/pyParOpt/ParOpt.py b/pyoptsparse/pyParOpt/ParOpt.py index e0e15be4..f719d709 100644 --- a/pyoptsparse/pyParOpt/ParOpt.py +++ b/pyoptsparse/pyParOpt/ParOpt.py @@ -212,6 +212,39 @@ def evalObjConGradient(self, x, g, A): A[i][:] = -gcon[i][:] return fail + def evalSparseCon(self, x, out): + """Evaluate the sparse constraints. + + Give the design variable vector x, compute the sparse constraints. + + Parameters + ---------- + x : array + Design variable vector + out : array + Sparse constraint values + """ + pass + + def addSparseJacobian(self, alpha, x, px, out): + """Compute the Jacobian-vector product of the sparse constraints. + + This code computes the action of the Jacobian of the sparse constraint matrix on the input vector px + , to compute out = alpha*J(x)*px. + + Parameters + ---------- + alpha : float + Scaling factor for the Jacobian-vector product + x : array + Design variable vector + px : array + Array to multiply the Jacobian by + out : array + Vector to store the result of the Jacobian-vector product + """ + pass + optTime = MPI.Wtime() # Optimize the problem