Optimal configuration models and efficient energy management strategies are developed based on a standalone energy system, including hydrogen fuel cell and photovoltaic (PV) in green buildings. To optimize a hybrid scheme, integer decision variables and continuous decision variables are considered as the number of scheme components. To the optimal size of the system, the objective function is defined based on the system annual cost and loss of power supply probability (LPSP) concept for reliability. To define the optimal solution to the optimization problem, the use of three modified harmony search (MHS) algorithms are proposed, namely, MHSLD, MHSWF, and MHSLWF. These methods are compared with modified and original HS algorithms. Furthermore, three loss of power supply probability values are introduced (1 %. 2 %, and 3 %) for the optimal power management. In this regard, the effect of the PV price and reservoir tank cost variation on the justification of the systems is investigated. The simulation results reveal that the MHSWF performs with high accuracy and robustness as it obtains the minimal values of the investigated indexes for different desired reliability, βL, (1 %, 2 %, and 3 %) in all simulation runs obtained. Therefore, the ranking order of the search power of the algorithms is MHSWF > MHSLD > MHSLWF > MHS > HS. For the desired βL with 1 %, MHSWF obtained the minimal SAC values and achieved cost savings of 0.8 %, 6.1 %, 11 %, and 20.2 % as compared with four other methods, and the saving reached up to 13.2 % in the costs for other βL values. The sensitivity analyses have been performed on the results of the modeling which reveals that by the increase of the desired βL (from 1 % to 3 %), the values of PV areas, and the number of hydrogen tanks decrease by 5.4 % and 31 %, respectively, while the value of SAC decreases by 31 %.In different desired βL, by decreasing the PV panel area cost, the value of SAC based on LPSP decreases, and by reducing the hydrogen tank cost of the system by 46 %, the SAC of the system based on LPSP decreased by 39 %.