I have made a function template PenaltyConstrained in optimizer.h . For now lets keep it simple and use only the given input parameters, hard code the multi-variable optimization algorithm which is to be used and any other parameters you need to call sub-functions; Checkout K. Deb pg: 154.