Necessary optimality conditions via image problem