United Nations Educational Scientic and Cultural Organization and International Atomic Energy Agency International Centre for Theoretical Physics Optimized Random Phase Approximation for Arbitrary Reference Systems: Extremum Conditions and Thermodynamic Consistence