-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add time_limit arg to the optimize api #28
Conversation
WalkthroughThe recent updates across various files have implemented a new feature that imposes a time constraint on optimization algorithms. A Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChat with CodeRabbit Bot (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (17)
- README.md (3 hunks)
- examples/quadratic_model.rs (3 hunks)
- examples/tsp_model.rs (7 hunks)
- src/optim/base.rs (2 hunks)
- src/optim/epsilon_greedy.rs (3 hunks)
- src/optim/generic.rs (3 hunks)
- src/optim/hill_climbing.rs (2 hunks)
- src/optim/logistic_annealing.rs (3 hunks)
- src/optim/relative_annealing.rs (3 hunks)
- src/optim/simulated_annealing.rs (3 hunks)
- src/optim/tabu_search.rs (3 hunks)
- src/tests/test_epsilon_greedy.rs (2 hunks)
- src/tests/test_hill_climbing.rs (2 hunks)
- src/tests/test_logistic_annealing.rs (2 hunks)
- src/tests/test_relative_annealing.rs (2 hunks)
- src/tests/test_simulated_annealing.rs (2 hunks)
- src/tests/test_tabu_search.rs (2 hunks)
Additional comments: 45
src/tests/test_hill_climbing.rs (2)
1-1: The addition of the
Duration
import is consistent with the PR's objective to introduce a time limit for optimization algorithms.14-21: The
optimize
method call correctly includes the newDuration::from_secs(10)
parameter as per the PR's objective to add a time limit to the optimization process.src/tests/test_epsilon_greedy.rs (2)
1-1: The addition of the
Duration
import is consistent with the PR's objective to introduce a time limit for optimization algorithms.14-21: The
optimize
method call correctly includes the newDuration::from_secs(10)
parameter as per the PR's objective to add a time limit to the optimization process.src/tests/test_logistic_annealing.rs (2)
1-1: The addition of the
Duration
import is consistent with the PR's objective to introduce a time limit for optimization algorithms.14-21: The
optimize
method call correctly includes the newDuration::from_secs(10)
parameter as per the PR's objective to add a time limit to the optimization process.src/tests/test_relative_annealing.rs (2)
1-1: The addition of the
Duration
import is consistent with the PR's objective to introduce a time limit for optimization algorithms.14-21: The
optimize
method call correctly includes the newDuration::from_secs(10)
parameter as per the PR's objective to add a time limit to the optimization process.src/tests/test_simulated_annealing.rs (2)
1-1: The addition of the
Duration
import is consistent with the PR's objective to introduce a time limit for optimization algorithms.14-21: The
optimize
method call correctly includes the newDuration::from_secs(10)
parameter as per the PR's objective to add a time limit to the optimization process.src/optim/base.rs (2)
1-1: The addition of the
Duration
import is consistent with the PR's objective to introduce a time limit for optimization algorithms.19-25: The
local_search
method signature has been correctly updated to include atime_limit: Duration
parameter, aligning with the PR's objective to add a time limit to the optimization process.src/tests/test_tabu_search.rs (2)
1-1: The addition of the
Duration
import is consistent with the PR's objective to introduce a time limit for optimization algorithms.45-52: The
optimize
method call correctly includes the newDuration::from_secs(10)
parameter as per the PR's objective to add a time limit to the optimization process.src/optim/hill_climbing.rs (2)
1-1: The addition of the
Duration
import is consistent with the PR's objective to introduce a time limit for optimization algorithms.36-54: The
optimize
method signature in theHillClimbingOptimizer
implementation has been correctly updated to include atime_limit: Duration
parameter, aligning with the PR's objective to add a time limit to the optimization process.src/optim/epsilon_greedy.rs (2)
1-1: The addition of the
Duration
import is consistent with the PR's objective to introduce a time limit for optimization algorithms.69-81: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [55-79]
The
optimize
method signature in theEpsilonGreedyOptimizer
implementation has been correctly updated to include atime_limit: Duration
parameter, aligning with the PR's objective to add a time limit to the optimization process.examples/quadratic_model.rs (3)
1-1: The import of
Duration
fromstd::time
is correctly added to demonstrate the use of the new time limit feature in the example.82-82: The declaration of the
time_limit
variable withDuration::from_secs_f32(1.0)
is correct and demonstrates the use of the new time limit feature in the example.92-92: The
optimize
function call in the example correctly includes thetime_limit
variable as an argument, demonstrating the new time limit feature.src/optim/relative_annealing.rs (2)
1-1: The addition of the
Duration
import is consistent with the PR's objective to introduce a time limit for optimization algorithms.75-88: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [61-85]
The
optimize
method signature in theRelativeAnnealingOptimizer
implementation has been correctly updated to include atime_limit: Duration
parameter, aligning with the PR's objective to add a time limit to the optimization process.src/optim/logistic_annealing.rs (3)
1-1: The addition of the
Duration
import is necessary for the newtime_limit
feature.63-63: The
time_limit
parameter has been correctly added to theoptimize
method signature.77-84: The
time_limit
parameter is correctly passed to theGenericLocalSearchOptimizer
'soptimize
method, ensuring the time constraint is applied.README.md (3)
20-20: The import statement in the README has been correctly updated to include
Duration
.101-101: The
time_limit
variable is correctly defined usingDuration::from_secs(60)
to represent a 60-second time limit.111-111: The
optimize
function call in the README example correctly includes thetime_limit
parameter, demonstrating the new feature usage.src/optim/simulated_annealing.rs (3)
1-5: The necessary imports for
Duration
andInstant
have been added to support the time limit feature.53-53: The
time_limit
parameter has been correctly added to theoptimize
method signature.77-80: The time tracking logic correctly checks if the
time_limit
has been exceeded and breaks out of the loop if it has.src/optim/generic.rs (3)
1-6: The imports for
Duration
andInstant
have been correctly added to support the time limit feature.77-77: The
time_limit
parameter has been correctly added to theoptimize
function signature.98-101: The time tracking logic within the
optimize
function correctly terminates the loop when thetime_limit
is exceeded.src/optim/tabu_search.rs (3)
1-6: The imports for
Duration
andInstant
have been correctly added to support the time limit feature.99-99: The
time_limit
parameter has been correctly added to thelocal_search
function signature.120-123: The time tracking logic within the
local_search
function correctly terminates the loop when thetime_limit
is exceeded.examples/tsp_model.rs (7)
1-1: The import of
Duration
fromcore::time
is correct and necessary for the new feature implementation.247-247: The
time_limit
variable is correctly created usingDuration::from_secs(60)
, which sets a 60-second limit for the optimization algorithms.271-271: The
time_limit
parameter is correctly passed to theHillClimbingOptimizer
'soptimize
function.290-290: The
time_limit
parameter is correctly passed to theTabuSearchOptimizer
'soptimize
function.308-308: The
time_limit
parameter is correctly passed to theSimulatedAnnealingOptimizer
'soptimize
function.326-326: The
time_limit
parameter is correctly passed to theEpsilonGreedyOptimizer
'soptimize
function.344-344: The
time_limit
parameter is correctly passed to theRelativeAnnealingOptimizer
'soptimize
function.
Summary by CodeRabbit
New Features
Documentation
Tests