Skip to content

SIANXKE-473: implement solver that directly uses the Gurobi API - #13

Open
MLackenbucher wants to merge 5 commits into
anexia:mainfrom
MLackenbucher:feature/MLA_SIANXKE-473_gurobi-without-ortools
Open

SIANXKE-473: implement solver that directly uses the Gurobi API#13
MLackenbucher wants to merge 5 commits into
anexia:mainfrom
MLackenbucher:feature/MLA_SIANXKE-473_gurobi-without-ortools

Conversation

@MLackenbucher

Copy link
Copy Markdown
Collaborator

No description provided.

Bumps [actions/setup-dotnet](https://github.com/actions/setup-dotnet) from 4 to 5.
- [Release notes](https://github.com/actions/setup-dotnet/releases)
- [Commits](actions/setup-dotnet@v4...v5)

---
updated-dependencies:
- dependency-name: actions/setup-dotnet
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
@codecov

codecov Bot commented Oct 17, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 53.64583% with 89 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.79%. Comparing base (035ca66) to head (6dbb108).

Files with missing lines Patch % Lines
...ia.MathematicalProgram/Solve/GurobiNativeSolver.cs 18.91% 58 Missing and 2 partials ⚠️
...c/Anexia.MathematicalProgram/Solve/IlpCbcSolver.cs 0.00% 8 Missing and 2 partials ⚠️
...aticalProgram/Solve/ConstraintProgrammingSolver.cs 0.00% 6 Missing and 1 partial ⚠️
src/Anexia.MathematicalProgram/Solve/IlpSolver.cs 84.00% 3 Missing and 1 partial ⚠️
src/Anexia.MathematicalProgram/Solve/LPSolver.cs 50.00% 3 Missing and 1 partial ⚠️
...nexia.MathematicalProgram/Result/ResultHandling.cs 96.07% 1 Missing and 1 partial ⚠️
...MathematicalProgram/Model/Expression/Constraint.cs 50.00% 1 Missing ⚠️
.../Anexia.MathematicalProgram/Result/SolverResult.cs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #13      +/-   ##
==========================================
+ Coverage   76.69%   79.79%   +3.10%     
==========================================
  Files          45       46       +1     
  Lines         811      980     +169     
  Branches       92      118      +26     
==========================================
+ Hits          622      782     +160     
- Misses        144      158      +14     
+ Partials       45       40       -5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread CHANGELOG.md Outdated
Comment thread README.md Outdated
Comment thread src/Anexia.MathematicalProgram/Solve/GurobiNativeSolver.cs Outdated
Comment thread src/Anexia.MathematicalProgram/Solve/GurobiNativeSolver.cs
Comment thread src/Anexia.MathematicalProgram/Solve/GurobiNativeSolver.cs Outdated
Comment thread src/Anexia.MathematicalProgram/Solve/GurobiNativeSolver.cs Outdated
Comment thread src/Anexia.MathematicalProgram/Solve/GurobiNativeSolver.cs Outdated
Comment thread test/Anexia.MathematicalProgram.Tests/Solve/GurobiSolverTest.cs Outdated
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v4...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
@MLackenbucher
MLackenbucher force-pushed the feature/MLA_SIANXKE-473_gurobi-without-ortools branch from 4c2f431 to a9068ae Compare November 27, 2025 13:58
…tions/checkout-6

Bump actions/checkout from 4 to 6
…tions/setup-dotnet-5

Bump actions/setup-dotnet from 4 to 5
@MLackenbucher
MLackenbucher force-pushed the feature/MLA_SIANXKE-473_gurobi-without-ortools branch 16 times, most recently from 9368d31 to 83baf76 Compare July 14, 2026 15:38
@MLackenbucher

Copy link
Copy Markdown
Collaborator Author

@melaniesi @sarahkatharina gerne auch mal drüber schauen und Anmerkungen geben wenn ihr noch welche habt

@MLackenbucher
MLackenbucher force-pushed the feature/MLA_SIANXKE-473_gurobi-without-ortools branch 2 times, most recently from ef0ddef to 003a7e4 Compare July 15, 2026 08:40
Comment on lines -22 to -26
- name: Verify commit exists in origin/main
run: |
git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
git branch --remote --contains | grep origin/main

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we should keep this check


<ItemGroup>
<PackageReference Update="Google.OrTools" Version="9.15.6755" />
<PackageReference Update="Google.OrTools" Version="9.14.6206" />

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why the downgrade?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

OR Tools 9.15.x has problems with Gurobi 13.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

waiting for google/or-tools#5272

Comment on lines +131 to +155
GRB.Status.OPTIMAL => objectiveValue is null || bestBound is null
? throw new MathematicalProgramException("Mathematical program could not be solved.")
: SolverResult(SolverResultStatus.Optimal, false, solutionValues, objectiveValue,
bestBound, true, true),
GRB.Status.SUBOPTIMAL => objectiveValue is null || bestBound is null
? throw new MathematicalProgramException("Mathematical program could not be solved.")
: SolverResult(SolverResultStatus.Feasible, false, solutionValues, objectiveValue,
bestBound, true),
GRB.Status.TIME_LIMIT => objectiveValue is null || bestBound is null
? throw new MathematicalProgramException("Mathematical program could not be solved.")
: SolverResult(SolverResultStatus.Timelimit, false, solutionValues, objectiveValue,
bestBound, true),
GRB.Status.INTERRUPTED => objectiveValue is null || bestBound is null
? throw new MathematicalProgramException("Mathematical program could not be solved.")
: SolverResult(SolverResultStatus.CancelledByUser, false, solutionValues, objectiveValue,
bestBound, true),
GRB.Status.MEM_LIMIT => objectiveValue is null || bestBound is null
? throw new MathematicalProgramException("Mathematical program could not be solved.")
: SolverResult(SolverResultStatus.UnknownStatus, false, solutionValues, objectiveValue,
bestBound, true),
GRB.Status.UNBOUNDED => objectiveValue is null || bestBound is null
? throw new MathematicalProgramException("Mathematical program could not be solved.")
: SolverResult<TVariable, TCoefficient, TVariableInterval>(SolverResultStatus.Unbounded, false),
GRB.Status.INFEASIBLE => SolverResult<TVariable, TCoefficient, TVariableInterval>(
SolverResultStatus.Infeasible, false, isFeasible: false),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think when can check objectiveValue is null || bestBound is null once before the switch

Comment on lines +84 to +89
if (solverParameter.ExportModelFilePath is not null)
{
logger?.LogInformation("Exporting model to {ExportModelFilePath}", solverParameter.ExportModelFilePath);

gurobiModel.Write(solverParameter.ExportModelFilePath);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

for long running models it might be sensible to move this export before the optimization

using Google.OrTools.ModelBuilder;
using Gurobi;
using Microsoft.Extensions.Logging;
using static Google.OrTools.Init.operations_research_init;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

remove unused import

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

one test, one assert

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

one test, one assert

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

one test, one assert

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

does any of these tests provide any value/insight/whatsoever?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Asserts correct solver initialization

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

one test, one assert

{
try
{
var env = new GRBEnv(true);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
var env = new GRBEnv(true);
using var env = new GRBEnv(true);


env.Start();

var gurobiModel = new GRBModel(env);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
var gurobiModel = new GRBModel(env);
using var gurobiModel = new GRBModel(env);

@MLackenbucher
MLackenbucher force-pushed the feature/MLA_SIANXKE-473_gurobi-without-ortools branch from 003a7e4 to 6dbb108 Compare August 3, 2026 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants