Clear Sky Science · en
Cost-effective and sustainable operation of microgrids using Improved Whale Optimization Algorithm
Why our future power grids need a new kind of “brain”
Keeping the lights on is getting trickier as more homes and businesses run on sun and wind instead of coal and gas. These clean sources are cheaper and better for the climate, but they come and go with the weather. This paper explores how a smarter digital “brain” can run small local power networks—known as microgrids—so they deliver reliable electricity at lower cost and with fewer emissions, even when the main grid is down. The authors show that a new computer algorithm, inspired by whale behavior, can cut operating costs for a test microgrid by nearly 40% compared with common planning methods.

Small power networks with big ambitions
Microgrids are compact power systems that might serve a neighborhood, a campus, or a village. Instead of relying only on distant power plants, they mix local sources such as solar panels, wind turbines, fuel cells, diesel generators, and battery storage. Microgrids can connect to the main utility grid when it is available, but they can also “island” and run independently during storms, wildfires, or blackouts. This flexibility makes them a promising building block for a cleaner and more resilient energy system—but also makes their operation more complex. Someone, or something, must constantly decide which devices to run, how much power to draw from or sell to the main grid, and when to charge or discharge batteries.
The role of a digital energy manager
To handle this complexity, microgrids use an Energy Management System, or EMS. The EMS gathers data on weather forecasts, electricity prices, equipment limits, battery charge levels, and customer demand. It then issues control commands—such as turning generators on or off, adjusting power output, and scheduling battery use—to meet several goals at once. These goals include keeping supply and demand in balance every hour, minimizing the total cost of operation, and cutting emissions from fossil-fueled generators. In grid-connected mode, the EMS also decides when it is smarter to buy cheap power from the main grid, and when to sell excess renewable electricity back, turning the microgrid into an active market player.
A whale-inspired way to search for better schedules
Deciding the best schedule for every generator and battery over a full day is a tough puzzle: there are many options, the costs are nonlinear, and renewable output is uncertain. Traditional mathematical methods or classic search algorithms often get stuck in mediocre solutions. The authors turn to a modern type of search called a metaheuristic, loosely modeled on how animals hunt or explore. Their Improved Whale Optimization Algorithm (IWOA) builds on an earlier method inspired by how humpback whales encircle prey and spiral inward. The improved version uses a carefully tuned “swimming” parameter, adaptive weights, and random long jumps known as Lévy flights to keep exploring widely at first and then home in on promising regions without getting trapped in local dead ends.

Testing the approach on a realistic microgrid
The team tested their EMS on a well-known benchmark: a low-voltage microgrid that combines a fuel cell, microturbine, diesel generator, solar panels, a wind turbine, and a battery connected to the main grid. They examined both islanded operation, where the microgrid must meet demand entirely from local resources, and grid-connected operation, where it can trade power with the larger network. In both modes, the algorithm sought to minimize a combined cost that includes fuel and maintenance for each device, the price of buying or selling electricity, and a penalty for emissions of carbon dioxide and other pollutants. The results showed that the EMS naturally favored cleaner and cheaper technologies, running the fuel cell as the main workhorse, using the microturbine as backup, and calling on the diesel only when absolutely necessary.
Smarter use of batteries and the main grid
A key finding is how the improved algorithm uses the battery and grid connection as financial and environmental levers. In islanded mode, the battery smooths swings in solar and wind output, discharging during high demand and charging when there is surplus renewable power, which reduces reliance on diesel fuel. In grid-connected mode, the EMS learns an “energy arbitrage” strategy: it charges the battery when grid electricity is cheap and discharges when prices peak, while also exporting extra renewable power when local demand and battery limits allow. Across many simulated days, the Improved Whale Optimization Algorithm cut microgrid operating costs by about 39.66% compared with traditional genetic algorithms, particle swarm methods, and the standard whale algorithm, all while keeping emissions lower.
What this means for everyday energy users
For non-specialists, the takeaway is simple: running a clean, reliable local power system is no longer just about buying hardware—it depends heavily on smart software. By giving microgrids a more capable “autopilot,” this whale-inspired algorithm lets them stretch each kilowatt-hour further, lean more on renewables, and rely less on polluting backup generators and costly grid imports. If deployed widely, such intelligent energy managers could make neighborhoods more resilient to outages, help utilities handle the rise of solar and wind without expensive upgrades, and support climate goals by automatically favoring cleaner power whenever it is available and affordable.
Citation: El-Zaher, S.M., Ahmed, A.M., Ahmed, E.M. et al. Cost-effective and sustainable operation of microgrids using Improved Whale Optimization Algorithm. Sci Rep 16, 4811 (2026). https://doi.org/10.1038/s41598-026-35529-y
Keywords: microgrids, energy management system, renewable energy, optimization algorithm, battery storage