Skip to content
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

Merged
merged 1 commit into from
Dec 26, 2023

Conversation

lucidfrontier45
Copy link
Owner

@lucidfrontier45 lucidfrontier45 commented Dec 26, 2023

Summary by CodeRabbit

  • New Features

    • Introduced a time limit parameter for optimization algorithms to control the duration of the optimization process.
  • Documentation

    • Updated examples and README to reflect the new time limit functionality.
  • Tests

    • Enhanced test cases to include the time limit parameter during optimization method calls.

@lucidfrontier45 lucidfrontier45 merged commit da49a03 into develop Dec 26, 2023
@lucidfrontier45 lucidfrontier45 deleted the feature/time-limit branch December 26, 2023 02:52
Copy link

coderabbitai bot commented Dec 26, 2023

Walkthrough

The recent updates across various files have implemented a new feature that imposes a time constraint on optimization algorithms. A time_limit parameter has been added, introducing a maximum duration for the optimization process, specifically affecting the behavior of the Hill Climbing algorithm and other related optimization methods.

Changes

Files Change Summary
README.md, examples/..._model.rs Added a time_limit variable and updated the optimize function call to incorporate this time constraint.
src/optim/... Introduced a time_limit parameter of type Duration to optimization methods to enable time-limited optimization.
src/tests/test_... Added an import for std::time::Duration and updated optimization method calls to include a time duration parameter.

🐇✨
To the tick of the clock, the algorithms race,
With a limit in time, they quicken their pace.
No longer they'll wander, in eternity's breath,
For the rabbit decrees, "Time bounds you, till rest."
⏳🌿

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?

Share

Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • You can directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
  • You can tag CodeRabbit on specific lines of code or entire files in the PR by tagging @coderabbitai in a comment. Examples:
    • @coderabbitai generate unit tests for this file
    • @coderabbitai modularize this function
  • You can tag @coderabbitai in a PR comment and ask questions about the PR and the codebase. Use quoted replies to pass the context for follow-up questions. Examples:
    • @coderabbitai gather interesting statistics about this repository and render them in a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai generate unit tests for the src/utils.ts file.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link

@coderabbitai coderabbitai bot left a 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

Commits Files that changed from the base of the PR and between 6da0a98 and d4d8d3a.
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 new Duration::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 new Duration::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 new Duration::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 new Duration::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 new Duration::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 a time_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 new Duration::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 the HillClimbingOptimizer implementation has been correctly updated to include a time_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 the EpsilonGreedyOptimizer implementation has been correctly updated to include a time_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 from std::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 with Duration::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 the time_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 the RelativeAnnealingOptimizer implementation has been correctly updated to include a time_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 new time_limit feature.

  • 63-63: The time_limit parameter has been correctly added to the optimize method signature.

  • 77-84: The time_limit parameter is correctly passed to the GenericLocalSearchOptimizer's optimize 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 using Duration::from_secs(60) to represent a 60-second time limit.

  • 111-111: The optimize function call in the README example correctly includes the time_limit parameter, demonstrating the new feature usage.

src/optim/simulated_annealing.rs (3)
  • 1-5: The necessary imports for Duration and Instant have been added to support the time limit feature.

  • 53-53: The time_limit parameter has been correctly added to the optimize 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 and Instant have been correctly added to support the time limit feature.

  • 77-77: The time_limit parameter has been correctly added to the optimize function signature.

  • 98-101: The time tracking logic within the optimize function correctly terminates the loop when the time_limit is exceeded.

src/optim/tabu_search.rs (3)
  • 1-6: The imports for Duration and Instant have been correctly added to support the time limit feature.

  • 99-99: The time_limit parameter has been correctly added to the local_search function signature.

  • 120-123: The time tracking logic within the local_search function correctly terminates the loop when the time_limit is exceeded.

examples/tsp_model.rs (7)
  • 1-1: The import of Duration from core::time is correct and necessary for the new feature implementation.

  • 247-247: The time_limit variable is correctly created using Duration::from_secs(60), which sets a 60-second limit for the optimization algorithms.

  • 271-271: The time_limit parameter is correctly passed to the HillClimbingOptimizer's optimize function.

  • 290-290: The time_limit parameter is correctly passed to the TabuSearchOptimizer's optimize function.

  • 308-308: The time_limit parameter is correctly passed to the SimulatedAnnealingOptimizer's optimize function.

  • 326-326: The time_limit parameter is correctly passed to the EpsilonGreedyOptimizer's optimize function.

  • 344-344: The time_limit parameter is correctly passed to the RelativeAnnealingOptimizer's optimize function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant