Hard constraint learning approaches with trainable influence functions for evolutionary equations