The diminishing supply of fossil fuels, such as carbon, oil, and petroleum, results from the world’s exponentially increasing energy consumption. The result is the greenhouse gases that cause climate change by trapping heat, contributing to respiratory disease from smog and air pollution. To address the aforementioned global problems, renewable energy, such as sun, wind, biomass, and tidal energy, has been employed in both small and large-scale energy systems 
. Global energy consumption will increase by over 25% by 2040 when renewable energy sources are expected to account for 40% of the world’s energy mix. Energy demand and supply must be balanced, which presents significant challenges for renewable energy sources 
. Because of the increasing demand for energy and the redesigning of power infrastructure, energy is now produced close to what is consumed. Renewable sources, particularly solar and wind power, have become less expensive and competitive to generate this electricity.
Several articles discuss microgrids (MG) 
, energy storage devices, and distributed generation (DG). A hybrid form of renewable energy battery power devices (and, in some situations, a diesel generator) is frequently the best option since it considers one or more renewable sources and is highly dependent on climatic and meteorological conditions 
. Electricity is frequently provided via hybrid energy systems for several standalone uses, including homes or farms in remote locations without grid extensions, telecommunication antennae, and equipment devices 
. Compared to systems that exclusively utilize one energy source, these hybrid solutions often indicate the highest reliability and lowest prices.
A microgrid comprises energy storage systems, various loads, and miniature power plants 
. A medium- or low-density distribution system dispersed generation using hybrid systems that combine renewable and traditional energy sources to produce electricity for end-user customers might be used to characterize it in a broader sense. Storage increases the microgrid’s dependability and is utilized to compensate for the PV’s sporadic nature and wind output electricity 
Real-time management requires communication networks which these microgrids have 
. Microgrids can also run independently and with a grid 
The injection of energy produced by decentralized power plants (wind and PV, …) to the grid, leads to the study of microgrids. DG distributed generators are also found in microgrids, which are based on converters and batteries. However, alternative systems are the most widely used, which encourages research in the field of DC and AC microgrids.
Hybrid, alternating current (AC), and direct current (DC) microgrids are the three types, depending on the source type they handle, as shown in Figure 1.
An integrated microgrid system 
Because power from variable distributed sources, such as solar and wind power systems, can fluctuate and is difficult to forecast dramatically to maintain stability in a microgrid, it is critical to conserve the balance of power supply and demand based on the accessibility of one of the main sources (solar irradiation and wind). The demand and supply equilibrium issue arises from the balance of power demand and supply, and there is just a small quantity of supply to balance the demand, which is much more crucial 
. Mana Managing microgrid energy optimization is typically as a challenge for offline optimization 
Microgrids powered by renewable energy sources are classified as “smart grids”, which provide various technology options for enabling communication between users and dispersed generations. When supported by a platform, an information system known as an energy management system (EMS) provides the necessary functionality to ensure that energy is produced, transmitted and distributed at the lowest possible cost 
. Microgrid energy management requires the implementation of a control program that allows the system to operate as efficiently as possible 
. This is accomplished by taking into account the two modes of operation for microgrids at the lowest possible cost (isolated and interconnected). When considering microgrids with renewable energy sources, it is critical to consider resource fluctuation, such as solar radiation 
2. Control of AC Microgrid
Three tiers make up the proposed hierarchical control structure: the droop approach serves as the main control and includes a virtual output impedance loop; the backup control enables reversing the primary control’s deviations; and the third control regulates the flow of electricity from the microgrid to the system for distributing power outside.
As seen in Figure 2, the microgrid control can be divided into three levels.
Figure 2. Hierarchy of the microgrid control.
2.1. Primary Control
The goal of this control is to maintain friability by adjusting the internal control loops for the current and voltage reference frequency and amplitude.
It employs the well-known P
P and Q are the active and reactive powers with P* and Q* as references, as illustrated in Figure 3.
Figure 3. P/Q method visualization.
E and ω are the voltage amplitude and the frequency, with E* and ω* their references.
Gp(s) and Gq(s) are linear transfer functions.
2.2. Secondary Control
Secondary control is proposed as a compensatory method for frequency and amplitude anomalies. To maintain the output voltage, the frequency and amplitude levels of the microgrid are measured and compared to MG and EMG references. Errors corrected by compensators are then transmitted to all MG units. The secondary control must reduce tolerable frequency variation to within 0.1 Hz in NE (north of Europe) or 0.2 Hz in UCTE (Union for the Coordination of Continental European Electricity Transmission 
). The integrating grid requirements improves stability.
The frequency and amplitude restoration controllers for an AC microgrid can be obtained similarly, as shown below:
Kp, Ki, Kp', and Ki' are the secondary control compensator’s parameters. In this instance, δω and δΕ must be constrained to stay within the range of permitted amplitude and frequency variations.
2.3. Third Control
Both reactive and active power fluxes can be exported or imported independently. The third control, energy management, aims to achieve this.
Control laws can be stated in the following expressions:
where the tertiary control compensator’s control parameters are Kp
, and Ki′
. In this situation, they are saturated if δE
are outside the permitted limits.
Notably, the reactive and active power fluxes depend on the Q′ and P omens and can be exported or imported separately.
3. Methods of Microgrid Optimization
An extensive robotic system is used for energy management in microgrids to ensure resource efficiency 
. Based on state-of-art information technology, it can optimize the administration of energy storage and decentralized energy source systems 
. Microgrid optimization frequently includes the following goals: increasing generator output power, minimizing microgrid operating costs, extending the life of storing energy systems, and lowering environmental costs.
Figure 4 shows the microgrid’s optimization methods.
Energy management methods 
3.1. Stochastic Optimization Techniques
Stochastic optimization methods can be used to raise the value of an objective function even when random variables are described by probabilistic functions. In stochastic programming, optimization can happen in one, two, or more phases. In the event that there are two phases, the optimization is split into two. At the initial step of optimization, the optimal point of operation using predicted data is selected. A disturbance simply prompts the real-time operation to correct the optimization using the actual value at step two. Normally, the first step considers every situation whereas the second stage just considers a select few.
3.2. Dynamic Programming
Using the dynamic programming method, the multi-period optimization can be broken down into time-indexed sub-problems. As a result, Bellman’s equation can be solved to identify the decision-making order. By breaking the problem down, the suggested solution resolves mixed-integer nonlinear programming brought on by practical considerations. This method may deal with stochasticity by incorporating empirical data with historical operational data. It reduces the dependency of optimality on forecast data by incorporating empirical knowledge into the real-time decision-making process.
3.3. Mixed Integer Programming and Non-Linear Programming
When variables can be discrete or continuous, optimization problems are addressed using mixed integer programming techniques. The methods are so ideal for EMS applications within microgrids. The development of mathematical models for the microgrid’s components aims to lower the cost function in MILP-based EMS. The MILP model evaluates wind speed, irradiation, load factors, and component cost parameters. The goal function and restrictions are non-linear rather than linear in mixed integer non-linear programming (MINLP) approaches. In order to create a linear model, MINLP models commonly require approximations. Continuous variables in MINLP models include the power produced by available generators, the electricity imported or exported at PCC, and the power injected by the ESS. When microgrids are taken into consideration, the power flow equation becomes more complex and nonlinear.
3.4. Artificial Intelligence
Moreover, microgrid optimization techniques based on multiagent systems enable decentralized administration of the microgrid and are made up of autonomously acting sections that carry out activities with predetermined goals. Communication between these agents also consists of loads, portable generators, and storage devices to achieve a low cost.
Specifically, in game theory, fuzzy logic, artificial neural networks, statistical techniques, and robust programming are employed to resolve optimization problems where the random variables are the parameters.
Combining the aforementioned techniques can lead to the development of additional methods, such as heuristic, stochastic, and enumeration algorithms.