Skip to content

changing defaults and tests to use highs instead of cbc#228

Merged
ParticularlyPythonicBS merged 5 commits intounstablefrom
feat/default_highs
Nov 27, 2025
Merged

changing defaults and tests to use highs instead of cbc#228
ParticularlyPythonicBS merged 5 commits intounstablefrom
feat/default_highs

Conversation

@ParticularlyPythonicBS
Copy link
Member

@ParticularlyPythonicBS ParticularlyPythonicBS commented Nov 26, 2025

Summary by CodeRabbit

  • New Features

    • HiGHS is now the default free solver option across configs and UI.
  • Documentation

    • Guides, quick-start, README, and examples updated to reference HiGHS and new sample configs.
  • Bug Fixes

    • More robust solver termination checks and objective value retrieval for reliable run detection.
  • Tests

    • Removed solver-specific availability tests; updated test configs to use HiGHS.
  • Chores

    • CI setup simplified by removing legacy solver installer steps; minor config formatting cleanup.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Nov 26, 2025

Walkthrough

Replaces CBC with HiGHS (appsi_highs) as the default solver across docs, configs, and tests; removes CBC installer steps from CI; deletes CBC availability checks and related CLI tests; and changes solver result validation to use Pyomo's check_optimal_termination() and model-level objective retrieval.

Changes

Cohort / File(s) Summary
CI workflow
\.github/workflows/ci.yml
Removed platform-specific CBC solver installation steps for Linux and macOS.
Documentation
README.md, docs/source/quick_start.rst
Made appsi_highs the default solver in docs/examples and added HiGHS to solver ecosystem; removed CBC-specific setup guidance.
Default & tutorial configs
data_files/my_configs/config_sample.toml, temoa/tutorial_assets/config_sample.toml
Switched solver_name from "cbc" to "appsi_highs"; added graphviz_output = false in tutorial config.
Test configs (suite)
tests/testing_configs/... (config_*.toml)
Switched solver_name from "cbc" to "appsi_highs" across test configuration files.
Test utilities configs
tests/utilities/... (config_*.toml)
Switched solver_name from "cbc" to "appsi_highs" and removed trailing blank lines/extra whitespace in some files.
CLI code
temoa/cli.py
Removed SOLVER_DOC_LINKS import, deleted _check_cbc_availability() helper, and removed CBC availability checks/messages from tutorial().
Solver result handling
temoa/_internal/run_actions.py
check_solve_status now uses check_optimal_termination(result); derives and logs termination_condition robustly; constructs non-optimal messages defensively from multiple possible result fields.
Tests — CLI
tests/test_cli.py
Removed tests asserting CBC presence/absence warnings (test_cli_tutorial_warns_if_cbc_missing, test_cli_tutorial_no_warn_if_cbc_present).
Tests — full runs
tests/test_full_runs.py
Added defensive checks that res is a SolverResults instance; use check_optimal_termination(res) and value(mdl.total_cost) to validate termination and objective value.

Sequence Diagram(s)

mermaid
sequenceDiagram
autonumber
participant User
participant CLI
participant Runner as Run_Actions
participant Solver
participant Pyomo

Note over CLI,Runner: Post-change flow (simplified)
User->>CLI: request tutorial or solve
CLI->>Runner: invoke solve
Runner->>Solver: run configured solver (e.g., appsi_highs)
Solver-->>Runner: returns result object
Runner->>Pyomo: check_optimal_termination(result)
alt optimal
    Pyomo-->>Runner: True
    Runner-->>CLI: report success
else not optimal
    Pyomo-->>Runner: False (termination_condition)
    Runner-->>CLI: report failure with derived status message

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Review focus:
    • temoa/_internal/run_actions.py — verify termination-condition extraction covers diverse solver result shapes.
    • tests/test_full_runs.py — confirm objective retrieval via value(mdl.total_cost) is correct for test models.
    • temoa/cli.py — ensure removal of CBC checks didn't drop needed solver documentation links.

Possibly related PRs

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changeset: replacing CBC solver with HiGHS as the default across configuration files, tests, and documentation.
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/default_highs

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9412fce and f1f186f.

📒 Files selected for processing (2)
  • temoa/_internal/run_actions.py (1 hunks)
  • tests/test_full_runs.py (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
tests/test_full_runs.py (1)
tests/legacy_test_values.py (1)
  • ExpectedVals (10-15)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: setup and test (macos-latest, 3.12)
  • GitHub Check: setup and test (macos-latest, 3.13)
🔇 Additional comments (3)
tests/test_full_runs.py (2)

12-12: LGTM! Imports correctly placed at module top.

The imports for check_optimal_termination and value are now properly located at the module level, following Python conventions.


52-71: Excellent solver-agnostic implementation with proper defensive checks.

The defensive checks ensure valid test fixture results, and the use of check_optimal_termination(res) with value(mdl.total_cost) correctly handles different solver result formats (legacy CBC vs. APPSI HiGHS). This addresses the previous review feedback completely.

temoa/_internal/run_actions.py (1)

304-353: Excellent solver-agnostic status checking implementation.

The enhanced check_solve_status function properly handles both legacy (CBC) and APPSI (HiGHS) result formats with comprehensive fallback logic. The defensive access patterns for termination_condition and status extraction are robust and well-structured.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
README.md (1)

174-186: Solver docs and examples are consistent; consider explicit link between appsi_highs and HiGHS

Using solver_name="appsi_highs" in the programmatic example, sample config, and configuration table matches the new “HiGHS as default” narrative and the solver dependency bullets that describe HiGHS via highspy with CBC as an alternative free solver. All of these pieces line up well.

One small clarity improvement you might consider: add a brief note somewhere near the first example or in the solver table that "appsi_highs is the Pyomo solver name for the HiGHS backend". That would help new users connect the code/config keyword with the HiGHS name mentioned in the prose.

Also applies to: 229-234, 246-247, 328-335

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5e9f6ec and a349102.

📒 Files selected for processing (23)
  • .github/workflows/ci.yml (0 hunks)
  • README.md (4 hunks)
  • data_files/my_configs/config_sample.toml (1 hunks)
  • docs/source/quick_start.rst (1 hunks)
  • temoa/cli.py (1 hunks)
  • temoa/tutorial_assets/config_sample.toml (2 hunks)
  • tests/test_cli.py (0 hunks)
  • tests/test_full_runs.py (1 hunks)
  • tests/testing_configs/config_annualised_demand.toml (1 hunks)
  • tests/testing_configs/config_emissions.toml (1 hunks)
  • tests/testing_configs/config_link_test.toml (1 hunks)
  • tests/testing_configs/config_materials.toml (1 hunks)
  • tests/testing_configs/config_mediumville.toml (1 hunks)
  • tests/testing_configs/config_seasonal_storage.toml (1 hunks)
  • tests/testing_configs/config_storageville.toml (1 hunks)
  • tests/testing_configs/config_survival_curve.toml (1 hunks)
  • tests/testing_configs/config_test_system.toml (1 hunks)
  • tests/testing_configs/config_utopia.toml (1 hunks)
  • tests/testing_configs/config_utopia_gv.toml (1 hunks)
  • tests/utilities/config_US_9R_8D.toml (1 hunks)
  • tests/utilities/config_mediumville.toml (1 hunks)
  • tests/utilities/config_test_system.toml (1 hunks)
  • tests/utilities/config_utopia.toml (1 hunks)
💤 Files with no reviewable changes (2)
  • tests/test_cli.py
  • .github/workflows/ci.yml
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-11-03T22:55:02.519Z
Learnt from: ParticularlyPythonicBS
Repo: TemoaProject/temoa PR: 186
File: temoa/_internal/temoa_sequencer.py:60-63
Timestamp: 2025-11-03T22:55:02.519Z
Learning: In `TemoaSequencer.__init__`, when a `mode_override` is provided, it must be written back to `self.config.scenario_mode` (not just stored in `self.temoa_mode`) because `HybridLoader.create_data_dict()` has strict consistency checks that validate `config.scenario_mode` matches the presence/absence of `myopic_index`. Without this synchronization, MYOPIC mode would fail with a RuntimeError when the loader is instantiated.

Applied to files:

  • temoa/cli.py
🧬 Code graph analysis (2)
temoa/cli.py (1)
temoa/core/config.py (1)
  • TemoaConfig (32-324)
tests/test_full_runs.py (1)
tests/legacy_test_values.py (1)
  • ExpectedVals (10-15)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: setup and test (macos-latest, 3.12)
  • GitHub Check: setup and test (macos-latest, 3.13)
🔇 Additional comments (13)
temoa/cli.py (1)

15-18: Import cleanup aligns CLI with config responsibilities

Restricting the import to TemoaConfig (dropping solver-doc linkage) matches the new “config handles solver availability” boundary and removes unused symbols. No issues spotted.

docs/source/quick_start.rst (1)

78-79: HiGHS solver note is clear and consistent

Stating that HiGHS is tested and available out-of-the-box matches the new default solver setup and other docs in this PR.

data_files/my_configs/config_sample.toml (1)

58-62: Sample config now aligned with new default solver

Setting solver_name = "appsi_highs" in the sample config matches the updated documentation and test configs that standardize on HiGHS/appsi_highs as the default solver.

tests/utilities/config_test_system.toml (1)

9-11: Utility test config updated to appsi_highs

Switching solver_name to "appsi_highs" keeps this utility config in sync with the project-wide default solver change.

tests/testing_configs/config_utopia.toml (1)

9-11: Utopia testing config matches new solver default

Using solver_name = "appsi_highs" here keeps the utopia test scenario aligned with the rest of the test suite and docs.

tests/testing_configs/config_annualised_demand.toml (1)

9-11: Annualised-demand testing config updated to appsi_highs

The solver switch to "appsi_highs" here is consistent with other testing configurations and the new default HiGHS-based solver choice.

tests/testing_configs/config_link_test.toml (1)

58-58: Approve solver default change from CBC to appsi_highs.

All configuration changes across these test files are consistent and correct. The solver migration is systematic and aligns with PR objectives.

Verify that appsi_highs is properly available in the test and CI environment. Also confirm that all configuration files across the codebase have been updated consistently.

tests/testing_configs/config_storageville.toml (1)

39-39: Solver default updated to HiGHS.

The configuration correctly updates the solver from CBC to appsi_highs, consistent with the PR objectives.

tests/utilities/config_US_9R_8D.toml (1)

10-10: Solver default updated to HiGHS.

The configuration correctly updates the solver from CBC to appsi_highs, consistent with the PR objectives and other test configurations.

tests/testing_configs/config_emissions.toml (1)

10-10: Solver default updated to HiGHS.

The configuration correctly updates the solver from CBC to appsi_highs, consistent with the PR objectives and other test configurations.

tests/utilities/config_mediumville.toml (1)

39-39: Solver default updated to HiGHS.

The configuration correctly updates the solver from CBC to appsi_highs, consistent with the PR objectives and other test configurations.

temoa/tutorial_assets/config_sample.toml (2)

59-60: Solver default updated to HiGHS with documentation reordering.

The configuration and inline documentation correctly update the solver from CBC to appsi_highs, with the comment reordered to list HiGHS first as the default option.


79-80: Verify graphviz_output configuration option is properly integrated.

Lines 79–80 introduce a new graphviz_output configuration option. This option does not appear in the other test configuration files (e.g., config_storageville.toml, config_emissions.toml). Clarify whether this option should also be present in test configs for consistency, and verify that the configuration parser and runtime code properly handle and validate this new option without breaking existing test runs.

@ParticularlyPythonicBS ParticularlyPythonicBS added the Maintenance Code quality fixes and deprecation management label Nov 26, 2025
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.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
temoa/_internal/run_actions.py (1)

281-284: Add defensive access to result['Solution'] in error handler.

Similar to the issue in check_solve_status, accessing result['Solution'].Status without verification can raise a KeyError with modern solver interfaces.

Apply this diff to handle this defensively:

             if result:
-                logger.error(
-                    'Solver reported termination condition (if any): %s', result['Solution'].Status
-                )
+                try:
+                    status = result['Solution'].Status
+                except (KeyError, AttributeError):
+                    status = getattr(result.solver, 'termination_condition', 'unknown')
+                logger.error('Solver reported termination condition (if any): %s', status)
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a349102 and 9412fce.

📒 Files selected for processing (1)
  • temoa/_internal/run_actions.py (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: setup and test (macos-latest, 3.12)
  • GitHub Check: setup and test (macos-latest, 3.13)
🔇 Additional comments (1)
temoa/_internal/run_actions.py (1)

19-19: LGTM: Solver-agnostic termination checking.

Adding check_optimal_termination is the recommended Pyomo approach for checking solver termination status across different solver interfaces.

@ParticularlyPythonicBS ParticularlyPythonicBS merged commit 01ce621 into unstable Nov 27, 2025
7 checks passed
@ParticularlyPythonicBS ParticularlyPythonicBS deleted the feat/default_highs branch November 27, 2025 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Maintenance Code quality fixes and deprecation management

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant