Skip to content

Commit

Permalink
removed hyperopt
Browse files Browse the repository at this point in the history
  • Loading branch information
SanPen committed May 21, 2024
1 parent 3332551 commit 8c4ca82
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 79 deletions.
50 changes: 11 additions & 39 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ pyqtdarktheme
nptyping
windpowerlib
pvlib
hyperopt
requests
pytest >= 7.2.0
rdflib
Expand Down
12 changes: 9 additions & 3 deletions src/GridCal/Gui/Diagrams/SchematicWidget/schematic_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -4858,12 +4858,18 @@ def get_devices_to_expand(circuit: MultiCircuit, root_bus: Bus, max_level: int =
list(fluid_nodes), fluid_paths)


def make_vecinity_diagram(circuit: MultiCircuit, root_bus: Bus, max_level: int = 1):
def make_vecinity_diagram(circuit: MultiCircuit,
root_bus: Bus,
max_level: int = 1,
prog_func: Union[Callable, None] = None,
text_func: Union[Callable, None] = None):
"""
Create a vecinity diagram
:param circuit: MultiCircuit
:param root_bus: Bus
:param max_level: max expansion level
:param prog_func:
:param text_func:
:return:
"""

Expand Down Expand Up @@ -4891,8 +4897,8 @@ def make_vecinity_diagram(circuit: MultiCircuit, root_bus: Bus, max_level: int =
fluid_nodes=list(fluid_nodes),
fluid_paths=fluid_paths,
explode_factor=1.0,
prog_func=None,
text_func=print,
prog_func=prog_func,
text_func=text_func,
name=root_bus.name + 'vecinity')

return diagram
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import numpy as np
import hyperopt
import functools

from typing import List, Dict
from GridCalEngine.Simulations.driver_template import DriverTemplate
from GridCalEngine.Simulations.PowerFlow.power_flow_driver import PowerFlowDriver, PowerFlowOptions
Expand Down Expand Up @@ -309,36 +306,6 @@ def independent_evaluation(self) -> None:

self.report_done()

def optimized_evaluation_hyperopt(self) -> None:
"""
Run an optimized investment evaluation without considering multiple evaluation groups at a time
"""

self.report_text("Evaluating investments with Hyperopt")

# number of random evaluations at the beginning
rand_evals = round(self.dim * 1.5)

# binary search space
space = [hyperopt.hp.randint(f'x_{i}', 2) for i in range(self.dim)]

if self.options.max_eval == rand_evals:
algo = hyperopt.rand.suggest
else:
algo = functools.partial(hyperopt.tpe.suggest, n_startup_jobs=rand_evals)

# compile the snapshot
self.results = InvestmentsEvaluationResults(investment_groups_names=self.grid.get_investment_groups_names(),
max_eval=self.options.max_eval + 1)

# add baseline
self.objective_function_so(combination=np.zeros(self.results.n_groups, dtype=int))

# run
results = hyperopt.fmin(self.objective_function_so, space, algo, self.options.max_eval)

self.report_done()

def optimized_evaluation_mvrsm(self) -> None:
"""
Run an optimized investment evaluation without considering multiple evaluation groups at a time
Expand Down Expand Up @@ -464,9 +431,6 @@ def run(self) -> None:
if self.options.solver == InvestmentEvaluationMethod.Independent:
self.independent_evaluation()

elif self.options.solver == InvestmentEvaluationMethod.Hyperopt:
self.optimized_evaluation_hyperopt()

elif self.options.solver == InvestmentEvaluationMethod.MVRSM:
self.optimized_evaluation_mvrsm_pareto()

Expand Down

0 comments on commit 8c4ca82

Please sign in to comment.