forked from MAGNET4Cardiac7T/hackathon
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
26 lines (22 loc) · 886 Bytes
/
main.py
File metadata and controls
26 lines (22 loc) · 886 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from src.costs.base import BaseCost
from src.costs import B1HomogeneityCost, B1HomogeneityMinMaxCost
from src.optimizers import DummyOptimizer, TorchOptimizer, MultiStartTorchOptimizer
from src.data import Simulation, CoilConfig
def run(simulation: Simulation, cost_function: BaseCost) -> CoilConfig:
"""
Main function to run the optimization, returns the best coil configuration
Args:
simulation: Simulation object
cost_function: Cost function object
timeout: Time (in seconds) after which the evaluation script will be terminated
"""
optimizer = MultiStartTorchOptimizer(
cost_function=cost_function,
downsampling_factor=2,
max_iter_explore=20,
num_starts=10,
max_iter_downsampled=865,
max_iter=100,
)
best_coil_config = optimizer.optimize(simulation)
return best_coil_config