On the costs of products in multi-task systems: theoretical development and application to a cogeneration engine