Skip to content

Feature/add ommx pyomo adapter#557

Draft
murayu-murayu wants to merge 3 commits intomainfrom
feature/add-ommx-pyomo-adapter
Draft

Feature/add ommx pyomo adapter#557
murayu-murayu wants to merge 3 commits intomainfrom
feature/add-ommx-pyomo-adapter

Conversation

@murayu-murayu
Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings July 8, 2025 02:20
@murayu-murayu murayu-murayu marked this pull request as draft July 8, 2025 02:21
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds a Pyomo-based adapter for OMMX v1 instances, with full solve, decode, and error‐handling support. It also includes comprehensive integration and error tests, plus project metadata and task automation.

  • Implement OMMXPyomoAdapter with variable, objective, and constraint mapping, plus solve/decode logic
  • Add integration tests covering LP, MILP, binary, maximize, constant, quadratic objectives/constraints
  • Add error tests for unsupported objectives/constraints, solver availability, and infeasible constants
  • Configure project metadata (pyproject.toml) and automation tasks (Taskfile.yml)

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/test_integration.py New integration tests for various problem types
tests/test_error.py New tests asserting adapter errors for unsupported features and infeasible cases
tests/test_adapter.py Basic adapter solve test verifying solution optimality
pyproject.toml Project metadata, version bump, dependencies, and classifiers
ommx_pyomo_adapter/exception.py Define OMMXPyomoAdapterError
ommx_pyomo_adapter/adapter.py Implement main adapter logic (solve, decode, variable/objective/constraint setup)
ommx_pyomo_adapter/init.py Expose public API
Taskfile.yml Define tasks for testing, linting, type checking, and default workflow
Comments suppressed due to low confidence (2)

python/ommx-pyomo-adapter/tests/test_integration.py:11

  • [nitpick] The parameter name 'generater' is misspelled; consider renaming it to 'generator' for clarity.
    "generater",

python/ommx-pyomo-adapter/pyproject.toml:19

  • The classifiers list both Apache Software License and MIT License, which may conflict; choose a single license to accurately reflect the project's licensing.
  "License :: OSI Approved :: Apache Software License",

Comment on lines +141 to +144
solver.solve(model)
# check objective
assert pyo.value(model.objective) == 0
state = adapter.decode_to_state(model)
Copy link

Copilot AI Jul 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

decode_to_state expects SolverResults, not a Pyomo model; store the solver result in a variable and pass it to decode_to_state (e.g., results = solver.solve(model); state = adapter.decode_to_state(results)).

Suggested change
solver.solve(model)
# check objective
assert pyo.value(model.objective) == 0
state = adapter.decode_to_state(model)
results = solver.solve(model)
# check objective
assert pyo.value(model.objective) == 0
state = adapter.decode_to_state(results)

Copilot uses AI. Check for mistakes.
Comment on lines +282 to +288
raise OMMXPyomoAdapterError(
f"Variable {var_name} has no value - model may not be solved"
)
entries[var.id] = value
return State(entries=entries)
except Exception as e:
raise OMMXPyomoAdapterError(f"Failed to decode state from results: {e}")
Copy link

Copilot AI Jul 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This specific error message is raised for missing variable values, but tests expect a generic 'Failed to decode state from results' message. Consider allowing the exception to be caught by the surrounding except block or updating the message format to match test expectations.

Suggested change
raise OMMXPyomoAdapterError(
f"Variable {var_name} has no value - model may not be solved"
)
entries[var.id] = value
return State(entries=entries)
except Exception as e:
raise OMMXPyomoAdapterError(f"Failed to decode state from results: {e}")
raise ValueError(
f"Variable {var_name} has no value - model may not be solved"
)
entries[var.id] = value
return State(entries=entries)
except Exception as e:
raise OMMXPyomoAdapterError("Failed to decode state from results") from e

Copilot uses AI. Check for mistakes.
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.

2 participants