Over the past decades, engineering systems have developed as networks of systems that deliver multiple services across multiple domains. This work aims to develop an optimization program for a dynamic, hetero-functional graph theory-based model of an engineering system. The manuscript first introduces a general approach to define a dynamic system model by integrating the device models in the hetero-functional graph theory structural model. To this end, the work leverages Petri net dynamics and the hetero-functional incidence tensor. The respective Petri net-based models are translated into the quadratic program canonical form to finalize the optimization program. The optimization program is demonstrated through the application of the program to a hydrogen-natural gas infrastructure test case. Four distinct scenarios are optimized to demonstrate potential synergies or cascading network effects of policy across infrastructures. This work develops the first hetero-functional graph theory-based optimization program and demonstrates that the program can be used to optimize flows across a multi-operand network, transform the operands in the network, store operands over time, analyze the behavior for a quadratic cost function, and implement it for a generic, continuous, large flexible engineering systems of arbitrary topology.