Fuel cells as clean power sources are very appealing to the maritime industry, which is committed to sustainability and reducing greenhouse gas and pollutant emissions from ships. Currently, power capacity, costs and lifetime of the fuel cell stack are the primary barriers. This report presents a mathematical model for optimizing the cost of gasoline with regard to hours from an hourly dispatch aboard a Marine Fuel Cell Power System (MFCPS) powered by hydrogen and gasoline. The model is based on a differential equation (DDP) that is used to determine the best energy the board procedure (EMS) for the typical power profile for each practical power source size mix Z. The proposed model is then used to calibrate the cost optimization findings for the constraint of hydrogen fuel (H2) tanks. The results show that there is no statistically significant difference between a non-hybrid energy system and a hybrid energy system that uses zero-emission hybrid energy systems. The suggested method's performance is demonstrated by examining hourly power dispatch statistics for the investigated ship over a one-year period.