OptimizeResult
IterationConditionCounter
¶
Bases: object
A class to keep track of the number of (consecutive) iterations that a condition has been met.
Attributes:
Name | Type | Description |
---|---|---|
_counter |
The number of consecutive iterations that the condition has been met. |
|
_nit |
The current iteration number. |
Source code in viprs/utils/OptimizeResult.py
counter
property
¶
Returns:
Type | Description |
---|---|
The number of consecutive iterations that the condition has been met. |
__init__()
¶
update(condition, iteration)
¶
Update the counter based on the condition.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
condition
|
The condition to check |
required | |
iteration
|
The current iteration |
required |
Source code in viprs/utils/OptimizeResult.py
OptimizeResult
¶
Bases: object
A class to store the results/progress of an optimization algorithm.
Similar to the OptimizeResult
class from scipy.optimize
,
but with a few additional fields and parameters.
Attributes:
Name | Type | Description |
---|---|---|
message |
A message about the optimization result |
|
stop_iteration |
A flag to indicate whether the optimization algorithm has stopped iterating |
|
success |
A flag to indicate whether the optimization algorithm has succeeded |
|
fun |
The current objective function value |
|
nit |
The current number of iterations |
|
error_on_termination |
A flag to indicate whether the optimization algorithm stopped due to an error. |
Source code in viprs/utils/OptimizeResult.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
|
converged
property
¶
Returns:
Type | Description |
---|---|
The flag indicating whether the optimization algorithm has converged. |
iterations
property
¶
Returns:
Type | Description |
---|---|
The current number of iterations. |
objective
property
¶
Returns:
Type | Description |
---|---|
The current value for the objective function. |
oscillation_counter
property
¶
Returns:
Type | Description |
---|---|
The number of oscillations in the objective function value. |
valid_optim_result
property
¶
Returns:
Type | Description |
---|---|
Boolean flag indicating whether the optimization result is valid in the sense tht it either successfully converged OR it stopped iterating without an error (due to e.g. reaching maximum number of iterations). |
reset()
¶
Reset the stored values to their initial state.
Source code in viprs/utils/OptimizeResult.py
update(fun, stop_iteration=False, success=False, message=None, increment=True)
¶
Update the stored values with new values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fun
|
The new objective function value |
required | |
stop_iteration
|
A flag to indicate whether the optimization algorithm has stopped iterating |
False
|
|
success
|
A flag to indicate whether the optimization algorithm has succeeded |
False
|
|
message
|
A detailed message about the optimization result. |
None
|
|
increment
|
A flag to indicate whether to increment the number of iterations. |
True
|