cirq_google.line.placement.anneal_minimize
Minimize solution using Simulated Annealing meta-heuristic.
cirq_google.line.placement.anneal_minimize(
initial: cirq_google.line.placement.optimization.T
,
cost_func: Callable[[T], float],
move_func: Callable[[T], T],
random_sample: Callable[[], float],
temp_initial: float = 0.01,
temp_final: float = 1e-06,
cooling_factor: float = 0.99,
repeat: int = 100,
trace_func: Optional[Callable[[T, float, float, float, bool], None]] = None
) -> cirq_google.line.placement.optimization.T
Args |
initial
|
Initial solution of type T to the problem.
|
cost_func
|
Callable which takes current solution of type T, evaluates it
and returns float with the cost estimate. The better solution is,
the lower resulting value should be; negative values are allowed.
|
move_func
|
Callable which takes current solution of type T and returns a
new solution candidate of type T which is random iteration over
input solution. The input solution, which is argument to this
callback should not be mutated.
|
random_sample
|
Callable which gives uniformly sampled random value from
the [0, 1) interval on each call.
|
temp_initial
|
Optional initial temperature for simulated annealing
optimization. Scale of this value is cost_func-dependent.
|
temp_final
|
Optional final temperature for simulated annealing
optimization, where search should be stopped. Scale of this value is
cost_func-dependent.
|
cooling_factor
|
Optional factor to be applied to the current temperature
and give the new temperature, this must be strictly greater than 0
and strictly lower than 1.
|
repeat
|
Optional number of iterations to perform at each given
temperature.
|
trace_func
|
Optional callback for tracing simulated annealing progress.
This is going to be called at each algorithm step for the arguments:
solution candidate (T), current temperature (float), candidate cost
(float), probability of accepting candidate (float), and acceptance
decision (boolean).
|
Returns |
The best solution found.
|
Raises |
ValueError
|
When supplied arguments are invalid.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-06-27 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
{"lastModified": "Last updated 2024-06-27 UTC."}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-06-27 UTC."],[],[]]