Conversation
…ency and add deprecation warning
…#75) Adds functional `modular_instance_generator` and related functions. It also refactors the organization of the module and deprecates the `InstanceGenerator` interface. - Implemented duration matrix generation with validation. - Created machine matrix generation functions with and without recirculation. - Developed modular instance generator for creating job shop instances. - Added release date matrix generation with various strategies. - Introduced size selectors for dynamic job and machine counts. - Added comprehensive tests for duration matrix, machine matrix, modular instance generator, release date matrix, and size selectors. - Removed outdated test file for generation utilities.
There was a problem hiding this comment.
Summary of Changes
Hello @Pabloo22, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request significantly upgrades the library's ability to generate job shop scheduling instances. The core change is the introduction of a highly modular and extensible instance generator, allowing for fine-grained control over instance characteristics like job arrival times and due dates. This enhancement provides greater flexibility for researchers and practitioners to create diverse and realistic problem instances for testing and development.
Highlights
- Modular Instance Generation: Introduced a new
modular_instance_generatorfunction that provides a flexible and composable way to create job shop instances with customizable properties, including arrival times, due dates, and deadlines. This new function replaces the deprecatedInstanceGeneratorandGeneralInstanceGeneratorinterfaces. - Enhanced Instance Properties: Added support for generating instances with release dates, deadlines, and due dates through dedicated matrix creation functions and various strategies (independent, cumulative, mixed).
- Refactored Generation Module: The instance generation logic has been significantly refactored into smaller, more focused modules (
_duration_matrix.py,_machine_matrix.py,_release_date_matrix.py,_size_selectors.py,_modular_instance_generator.py) for improved maintainability and extensibility. - New Tutorial and Documentation Updates: A new tutorial, 'Generating New Problems', has been added to guide users on how to leverage the new modular instance generation capabilities. The
README.mdand existing tutorials have been updated to reflect these changes and the new file structure. - Deprecation of Old Attributes: The
durations_matrixanddurations_matrix_arrayattributes inJobShopInstancehave been deprecated in favor ofduration_matrixandduration_matrix_arrayfor naming consistency. - New Benchmark Loading Utility: A
load_benchmark_groupfunction has been added to the benchmarking module, allowing users to load multiple benchmark instances that share a common naming prefix.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Pull Request Overview
This pull request adds a comprehensive modular instance generation system for creating job shop instances with support for arrival times, due dates, and deadlines. The PR refactors the generation module organization and deprecates the InstanceGenerator interface.
- Implements a new
modular_instance_generatorfunction with dependency injection for flexible instance creation - Adds duration, machine, and release date matrix generation with various strategies and validation
- Introduces size selectors for dynamic job and machine count selection
- Updates property naming from
durations_matrixtoduration_matrixfor consistency
Reviewed Changes
Copilot reviewed 23 out of 24 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| job_shop_lib/_job_shop_instance.py | Updates property naming from durations_matrix to duration_matrix with backward compatibility |
| job_shop_lib/generation/ | Adds modular generation components including size selectors, matrix creators, and instance generator |
| job_shop_lib/benchmarking/ | Adds load_benchmark_group function for loading benchmark instance groups |
| tests/ | Comprehensive test coverage for new generation functionality and updated property names |
| docs/ | Adds tutorial for generating new problems and updates simulated annealing tutorial |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Code Review
This pull request introduces a significant and valuable refactoring of the instance generation module, making it more modular and extensible. The new modular_instance_generator is a great addition, and the accompanying tutorial is very helpful. The code is well-structured, and the addition of comprehensive tests is commendable.
My review focuses on a few key areas:
- A critical bug in the machine matrix generation that leads to incorrect instance dimensions.
- A performance regression in
JobShopInstancedue to incorrect caching of properties. - Minor issues in documentation and code consistency.
Overall, this is a great feature, and with a few fixes, it will be a solid improvement to the library.
| return generate_machine_matrix_with_recirculation( | ||
| num_jobs, num_machines, numpy_rng | ||
| ).tolist() |
There was a problem hiding this comment.
The generate_machine_matrix_with_recirculation function returns a matrix of shape (num_machines, num_jobs). However, other parts of the generation pipeline, like JobShopInstance.from_matrices, expect a machine matrix of shape (num_jobs, num_machines). This will lead to incorrectly generated instances. The matrix should be transposed before being returned.
| return generate_machine_matrix_with_recirculation( | |
| num_jobs, num_machines, numpy_rng | |
| ).tolist() | |
| return generate_machine_matrix_with_recirculation( | |
| num_jobs, num_machines, numpy_rng | |
| ).T.tolist() |
| " for d in job_row:\n", | ||
| " cum += d\n", | ||
| " # 25% slack factor (matches markdown description)\n", | ||
| " row.append(int(math.ceil(cum * 2)))\n", |
There was a problem hiding this comment.
There's a discrepancy between the markdown description and the code for calculating deadlines. The markdown states that deadlines are calculated as cumulative_duration * 1.25, but the code uses cum * 2. The comment in the code also refers to a "25% slack factor", which corresponds to multiplying by 1.25, not 2. Please align the code with the description to avoid confusion.
row.append(int(math.ceil(cum * 1.25)))
| A dictionary containing the names of the benchmark instances as keys | ||
| and the corresponding :class:`JobShopInstance` objects as values. |
There was a problem hiding this comment.
The docstring here states that the function returns a dictionary, but the function signature and implementation indicate it returns a list of JobShopInstance objects. Please update the docstring to match the return type.
| A dictionary containing the names of the benchmark instances as keys | |
| and the corresponding :class:`JobShopInstance` objects as values. | |
| A list of :class:`JobShopInstance` objects whose names start with the given | |
| prefix. |
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
instead of the deprecated `durations_matrix_array`
…rculation` Correct machine matrix shape and add validation for job and machine counts
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 25 out of 25 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
job_shop_lib/generation/_machine_matrix.py:74
- The docstring states the return shape is (num_machines, num_jobs) but the actual implementation returns shape (num_jobs, num_machines) as seen in line 84. The documentation should be corrected to match the implementation.
A machine matrix with recirculation with shape (num_machines,
num_jobs).
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Adds functional
modular_instance_generatorand related functions. It also refactors the organization of the module and deprecates theInstanceGeneratorinterface.Extra:
load_benchmark_groupfunctionduration_matrixandduration_matrix_array(deprecatesdurations_matrixanddurations_matrix_array) toJobShopInstance.