basic_optimalization
Classes¤
BaseOptimalization ¤
BaseOptimalization(
working_dir="",
distribution_file="generator.in",
run_file="photo_track.in",
log_dir="log",
log_file_name="log.log",
console_log=True,
do_final_run=True,
n_parallel=5,
)
Bases: OptimalizationCore
Parameters:
Name | Type | Description | Default |
---|---|---|---|
working_dir |
str | Path
|
Name of the working directory (can be relative path). Defaults to "". |
''
|
distribution_file |
str | Path
|
Name of the ASTRA distribution file. Defaults to "generator.in". |
'generator.in'
|
run_file |
str | Path
|
Name of the ASTRA run file. Defaults to "photo_track.in". |
'photo_track.in'
|
log_dir |
str | Path
|
Name of the log directory, that will be created inside the working directory (can be relative path). Defaults to "log". |
'log'
|
log_file_name |
str
|
Name of the log file. Defaults to "log.log". |
'log.log'
|
console_log |
bool
|
If False, the log will not be written to the console. Defaults to False. |
True
|
logger_name |
str | None
|
Name of the logger for possible logger sharing. If set to None, new logger will be created. Defaults to None. |
required |
do_final_run |
(bool, True)
|
If True, one last run with the optimised settings will be performed for the analysis. |
True
|
n_parallel |
(int, 5)
|
Number of parallel ASTRA simulations to be run. Typically limited by the CPU power. Test how many simulations your computer can run at a same time. |
5
|
Source code in optimalization/basic_optimalization.py
Functions¤
_set_optimal_parameter_value ¤
Set the parameter to given optimal value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scanning_parameter |
str
|
Parameter to be changed to the optimal value. |
required |
optimal |
(str, int)
|
Optimal value to be set. |
required |
Source code in optimalization/basic_optimalization.py
add_optimalization_parameter ¤
Add parameter which has to be minimized (maximised if weight is set to negative).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
optimalization_parameter |
str
|
Name of the parameter. |
required |
weight |
float
|
Weight of the parameter (higher value, higher impact on the optimalization). |
required |
Source code in optimalization/basic_optimalization.py
add_scanning_parameter ¤
add_scanning_parameter(
scanning_parameter,
min_value,
max_value,
step=None,
n_steps=None,
only_scan=False,
)
Method to add a parameter to scan.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scanning_parameter |
str
|
Name of the scanning parameter |
required |
min_value |
(str, int)
|
Starting value of the scan. |
required |
max_value |
(str, int)
|
Final value of the scan. |
required |
step |
(str, int)
|
Size of the steps. Defaults to None. If not specified, the number of steps (n_steps) argument is taken. |
None
|
n_steps |
(str, int)
|
Number of steps to be taken. Defaults to None. If not specified, the step size (step) argument is taken. |
None
|
only_scan |
bool
|
If True, only scan is performed and the outcome is not used to optimalization. Defaults to False. |
False
|
Raises:
Type | Description |
---|---|
Exception
|
Raised if neither number of steps (n_step) nor step size (step) is given. |
Source code in optimalization/basic_optimalization.py
find_optimal_value ¤
Method to find and optimal value of the scanning_parameter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scanning_parameter |
str
|
Name of the parameter. |
required |
scanning_dir |
Path
|
Location of the performed scan. |
required |
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
Optimal value of the scanning_parameter. |
Source code in optimalization/basic_optimalization.py
optimize ¤
Method to run the optimalization.
Source code in optimalization/basic_optimalization.py
run_final ¤
Method to run the final scan.
Source code in optimalization/basic_optimalization.py
run_scan_of_parameter ¤
Method to run the scan of parameter. Returns the optimal value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scanning_parameter |
str
|
Name of the parameter to be scanned and optimized |
required |
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
optimal value of the scanning_parameter |
Source code in optimalization/basic_optimalization.py
save_final_run_characteristics ¤
Method to save the final run charateristics.
Source code in optimalization/basic_optimalization.py
Created: October 31, 2023