diff --git a/src/ComputingTasks.cc b/src/ComputingTasks.cc
index 00f31006040cdc076fab7e7c61703e3e73597d57..8ac32251dc412d6f37e7630cb694fe9467b8036d 100644
--- a/src/ComputingTasks.cc
+++ b/src/ComputingTasks.cc
@@ -2175,6 +2175,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.get_computed_derivs_order() ? -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..2ab7320f1659af3a58ef3fa21c134c32e85c53c8 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 vector<int>
+  getNNZDerivatives() const
+  {
+    return NNZDerivatives;
+  }
+
+  //!Returns the maximum order of computed derivatives
+  inline int
+  get_computed_derivs_order() const
+  {
+    return computed_derivs_order;
+  }
+
   inline static string
   BlockSim(BlockSimulationType type)
   {