Skip to content

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

Open
MLackenbucher wants to merge 1 commit intoanexia: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 1 commit intoanexia:mainfrom
MLackenbucher:feature/MLA_SIANXKE-473_gurobi-without-ortools

Conversation

@MLackenbucher
Copy link
Collaborator

No description provided.

@codecov
Copy link

codecov bot commented Oct 17, 2025

Codecov Report

❌ Patch coverage is 7.09220% with 131 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.20%. Comparing base (c30ab3d) to head (a9068ae).

Files with missing lines Patch % Lines
...ia.MathematicalProgram/Solve/GurobiNativeSolver.cs 0.00% 70 Missing ⚠️
...nexia.MathematicalProgram/Result/ResultHandling.cs 0.00% 50 Missing ⚠️
src/Anexia.MathematicalProgram/Solve/IlpSolver.cs 0.00% 7 Missing ⚠️
...icalProgram/SolverConfiguration/SolverParameter.cs 75.00% 2 Missing and 1 partial ⚠️
...MathematicalProgram/Model/Expression/Constraint.cs 50.00% 1 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (c30ab3d) and HEAD (a9068ae). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (c30ab3d) HEAD (a9068ae)
2 1
Additional details and impacted files
@@             Coverage Diff             @@
##             main      #13       +/-   ##
===========================================
- Coverage   76.69%   66.20%   -10.49%     
===========================================
  Files          45       46        +1     
  Lines         811      944      +133     
  Branches       92      115       +23     
===========================================
+ Hits          622      625        +3     
- Misses        144      274      +130     
  Partials       45       45               

☔ View full report in Codecov by Sentry.
📢 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.

CHANGELOG.md Outdated
- Added possibility to use Gurobi Solver directly via the API, not using Google OR-Tools.

### Changed
- Usage of AdditionalSolverParmateters. Changed list of string to list ob key-value pairs.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- Usage of AdditionalSolverParmateters. Changed list of string to list ob key-value pairs.
- Usage of AdditionalSolverParmateters. Changed list of string to list of key-value pairs.

README.md Outdated
Comment on lines +102 to +103
- Key mapping shortcuts are applied for NumberOfThreads and RelativeGap; AdditionalSolverSpecificParameters are forwarded as-is.
- TimeLimitInMilliseconds is mapped to the solver’s native time limit.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- Key mapping shortcuts are applied for NumberOfThreads and RelativeGap; AdditionalSolverSpecificParameters are forwarded as-is.
- TimeLimitInMilliseconds is mapped to the solver’s native time limit.
- The AdditionalSolverSpecificParameters are forwarded as-is.
- NumberOfThreads, TimeLimitInMilliseconds, and RelativeGap is mapped to the solver’s native time limit.

: MemberwiseEquatable<IlpSolver>,
IOptimizationSolver<IIntegerVariable<IRealScalar>, IRealScalar, IRealScalar, RealScalar>
{
private ILogger<IlpSolver>? Logger { get; } = logger;
Copy link
Contributor

Choose a reason for hiding this comment

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

we don't need an extra property we can use the primary constructor parameter directly.

env.Start();
var gurobiModel = new GRBModel(env);


Copy link
Contributor

Choose a reason for hiding this comment

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

remove empty line

gurobiModel.AddVar(item.Interval.LowerBound.Value, item.Interval.UpperBound.Value, 0, GRB.INTEGER,
item.Name));

var cnt = 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

use descriptive variable name


gurobiModel.Optimize();


Copy link
Contributor

Choose a reason for hiding this comment

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

remove empty line

Comment on lines +99 to +103
catch (Exception e)
{
Logger?.LogError(e, "An error occurred during solving the model: {EMessage}", e.Message);
throw;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

remove try catch to fix warning


namespace Anexia.MathematicalProgram.Tests.Solve;

public sealed class GurobiSolverTest
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public sealed class GurobiSolverTest
public sealed class GurobiNativeSolverTest

@MLackenbucher MLackenbucher force-pushed the feature/MLA_SIANXKE-473_gurobi-without-ortools branch from 4c2f431 to a9068ae Compare November 27, 2025 13:58
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