diff --git a/src/ComputingTasks.cc b/src/ComputingTasks.cc
index 891fa5ca2af5507c202d8bb53445fa5d948fa5ad..fcf94a423543f48e9f2123a465b7712e8ec78bc5 100644
--- a/src/ComputingTasks.cc
+++ b/src/ComputingTasks.cc
@@ -2225,6 +2225,10 @@ PlannerObjectiveStatement::computingPass()
 void
 PlannerObjectiveStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
 {
+  output << "M_.NNZDerivatives_objective = [";
+  for (int i=1; i < static_cast<int>(model_tree.getNNZDerivatives().size()); i++)
+    output << (i > model_tree.getComputedDerivsOrder() ? -1 : model_tree.getNNZDerivatives()[i]) << ";";
+  output << "];";
   model_tree.writeStaticFile(basename + ".objective", false, false, false, "", {}, {}, false);
 }
 
diff --git a/src/ModelTree.hh b/src/ModelTree.hh
index e075e612508333ee4ee05c6523a70a30ab0ce525..6cfdfcf6932469dcac7394fbe0641bb75b650f44 100644
--- a/src/ModelTree.hh
+++ b/src/ModelTree.hh
@@ -455,6 +455,20 @@ public:
     return equation_tags.getTagsByEqn(eq);
   }
 
+  //! Returns the vector of non-zero derivative counts
+  inline const vector<int> &
+  getNNZDerivatives() const
+  {
+    return NNZDerivatives;
+  }
+
+  //!Returns the maximum order of computed derivatives
+  inline int
+  getComputedDerivsOrder() const
+  {
+    return computed_derivs_order;
+  }
+
   inline static string
   BlockSim(BlockSimulationType type)
   {