Skip to content

Commit

Permalink
Merge pull request #544 from BDonnot/bd_dev
Browse files Browse the repository at this point in the history
2 minor improvments
  • Loading branch information
BDonnot authored Oct 26, 2023
2 parents e735c5a + bbcf404 commit 123102f
Show file tree
Hide file tree
Showing 7 changed files with 215 additions and 113 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Change Log
- [???] "asynch" multienv
- [???] properly model interconnecting powerlines

[1.9.6] - 2023-xx-yy
[1.9.6] - 2023-10-26
----------------------
- [BREAKING] when a storage is connected alone on a bus, even if it produces / absorbs 0.0 MW it
will raise a diverging powerflow error (previously the storage was automatically disconnected by
Expand Down Expand Up @@ -64,6 +64,8 @@ Change Log
- [IMPROVED] handling of environments without shunts
- [IMPROVED] error messages when grid is not consistent
- [IMPROVED] add the default `l2rpn_case14_sandbox` environment in all part of the docs (substituing `rte_case14_realistic` or nothing)
- [IMPROVED] imports on the `Exceptions` module
- [IMPROVED] pandapower backend raises `BackendError` when "diverging"

[1.9.5] - 2023-09-18
---------------------
Expand Down
2 changes: 1 addition & 1 deletion grid2op/Backend/pandaPowerBackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,7 @@ def runpf(self, is_dc : bool=False) -> Tuple[bool, Union[Exception, None]]:
# of the powerflow has not converged, results are Nan
self._reset_all_nan()
msg = exc_.__str__()
return False, DivergingPowerFlow(f'powerflow diverged with error :"{msg}"')
return False, BackendError(f'powerflow diverged with error :"{msg}"')

def assert_grid_correct(self) -> None:
"""
Expand Down
27 changes: 27 additions & 0 deletions grid2op/Exceptions/BackendExceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,30 @@ class BackendError(Grid2OpException):
"""

pass


class DivergingPowerflow(BackendError):
"""Specific error that should be raised when the powerflow diverges
"""
pass


class IslandedGrid(BackendError):
"""Specific error when then backend "fails" because of an islanded grid"""
pass


class IsolatedElement(IslandedGrid):
"""Specific error that should be raised when a element is alone on a bus (islanded grid when only one element is islanded)
"""
pass


class DisconnectedLoad(BackendError):
"""Specific error raised by the backend when a load is disconnected"""
pass


class DisconnectedGenerator(BackendError):
"""Specific error raised by the backend when a generator is disconnected"""
pass
112 changes: 62 additions & 50 deletions grid2op/Exceptions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@
"ChronicsNotFoundError",
"InsufficientData",
"BackendError",
"DivergingPowerflow",
"IslandedGrid",
"IsolatedElement",
"DisconnectedLoad",
"DisconnectedGenerator",
"PlotError",
"OpponentError",
"UsedRunnerError",
Expand All @@ -59,63 +64,70 @@

from grid2op.Exceptions.Grid2OpException import Grid2OpException

from grid2op.Exceptions.EnvExceptions import EnvError
from grid2op.Exceptions.EnvExceptions import IncorrectNumberOfLoads
from grid2op.Exceptions.EnvExceptions import IncorrectNumberOfGenerators
from grid2op.Exceptions.EnvExceptions import IncorrectNumberOfLines
from grid2op.Exceptions.EnvExceptions import IncorrectNumberOfSubstation
from grid2op.Exceptions.EnvExceptions import IncorrectNumberOfStorages
from grid2op.Exceptions.EnvExceptions import IncorrectNumberOfElements
from grid2op.Exceptions.EnvExceptions import IncorrectPositionOfLoads
from grid2op.Exceptions.EnvExceptions import IncorrectPositionOfGenerators
from grid2op.Exceptions.EnvExceptions import IncorrectPositionOfLines
from grid2op.Exceptions.EnvExceptions import IncorrectPositionOfStorages
from grid2op.Exceptions.EnvExceptions import UnknownEnv
from grid2op.Exceptions.EnvExceptions import MultiEnvException
from grid2op.Exceptions.EnvExceptions import (EnvError,
IncorrectNumberOfLoads,
IncorrectNumberOfGenerators,
IncorrectNumberOfLines,
IncorrectNumberOfSubstation,
IncorrectNumberOfStorages,
IncorrectNumberOfElements,
IncorrectPositionOfLoads,
IncorrectPositionOfGenerators,
IncorrectPositionOfLines,
IncorrectPositionOfStorages,
UnknownEnv,
MultiEnvException)

from grid2op.Exceptions.IllegalActionExceptions import IllegalAction
from grid2op.Exceptions.IllegalActionExceptions import OnProduction
from grid2op.Exceptions.IllegalActionExceptions import VSetpointModified
from grid2op.Exceptions.IllegalActionExceptions import ActiveSetPointAbovePmax
from grid2op.Exceptions.IllegalActionExceptions import ActiveSetPointBelowPmin
from grid2op.Exceptions.IllegalActionExceptions import OnLoad
from grid2op.Exceptions.IllegalActionExceptions import OnLines
from grid2op.Exceptions.IllegalActionExceptions import InvalidReconnection
from grid2op.Exceptions.IllegalActionExceptions import (
UnitCommitorRedispachingNotAvailable,
)
from grid2op.Exceptions.IllegalActionExceptions import (IllegalAction,
OnProduction,
VSetpointModified,
ActiveSetPointAbovePmax,
ActiveSetPointBelowPmin,
OnLoad,
OnLines,
InvalidReconnection,
UnitCommitorRedispachingNotAvailable,
)

from grid2op.Exceptions.AmbiguousActionExceptions import NotEnoughGenerators
from grid2op.Exceptions.AmbiguousActionExceptions import GeneratorTurnedOffTooSoon
from grid2op.Exceptions.AmbiguousActionExceptions import GeneratorTurnedOnTooSoon
from grid2op.Exceptions.AmbiguousActionExceptions import InvalidRedispatching
from grid2op.Exceptions.AmbiguousActionExceptions import InvalidBusStatus
from grid2op.Exceptions.AmbiguousActionExceptions import InvalidNumberOfObjectEnds
from grid2op.Exceptions.AmbiguousActionExceptions import InvalidNumberOfLines
from grid2op.Exceptions.AmbiguousActionExceptions import InvalidNumberOfGenerators
from grid2op.Exceptions.AmbiguousActionExceptions import InvalidNumberOfLoads
from grid2op.Exceptions.AmbiguousActionExceptions import InvalidCurtailment
from grid2op.Exceptions.AmbiguousActionExceptions import UnrecognizedAction
from grid2op.Exceptions.AmbiguousActionExceptions import InvalidLineStatus
from grid2op.Exceptions.AmbiguousActionExceptions import InvalidStorage
from grid2op.Exceptions.AmbiguousActionExceptions import AmbiguousAction
from grid2op.Exceptions.AmbiguousActionExceptions import NonFiniteElement
from grid2op.Exceptions.AmbiguousActionExceptions import AmbiguousActionRaiseAlert
from grid2op.Exceptions.AmbiguousActionExceptions import (NotEnoughGenerators,
GeneratorTurnedOffTooSoon,
GeneratorTurnedOnTooSoon,
InvalidRedispatching,
InvalidBusStatus,
InvalidNumberOfObjectEnds,
InvalidNumberOfLines,
InvalidNumberOfGenerators,
InvalidNumberOfLoads,
InvalidCurtailment,
UnrecognizedAction,
InvalidLineStatus,
InvalidStorage,
AmbiguousAction,
NonFiniteElement,
AmbiguousActionRaiseAlert)

from grid2op.Exceptions.PowerflowExceptions import DivergingPowerFlow

from grid2op.Exceptions.ObservationExceptions import BaseObservationError
from grid2op.Exceptions.ObservationExceptions import NoForecastAvailable
from grid2op.Exceptions.ObservationExceptions import SimulateError
from grid2op.Exceptions.ObservationExceptions import SimulateUsedTooMuchThisStep
from grid2op.Exceptions.ObservationExceptions import SimulateUsedTooMuchThisEpisode
from grid2op.Exceptions.ObservationExceptions import (BaseObservationError,
NoForecastAvailable,
SimulateError,
SimulateUsedTooMuchThisStep,
SimulateUsedTooMuchThisEpisode)

from grid2op.Exceptions.ChronicsExceptions import ChronicsError
from grid2op.Exceptions.ChronicsExceptions import ChronicsNotFoundError
from grid2op.Exceptions.ChronicsExceptions import InsufficientData
from grid2op.Exceptions.handlers_exceptions import HandlerError
from grid2op.Exceptions.ChronicsExceptions import (ChronicsError,
ChronicsNotFoundError,
InsufficientData,
)
from grid2op.Exceptions.handlers_exceptions import (HandlerError,
)

from grid2op.Exceptions.BackendExceptions import BackendError
from grid2op.Exceptions.BackendExceptions import (BackendError,
DivergingPowerflow,
IslandedGrid,
IsolatedElement,
DisconnectedLoad,
DisconnectedGenerator,
)

from grid2op.Exceptions.PlotExceptions import PlotError

Expand Down
Loading

0 comments on commit 123102f

Please sign in to comment.