Skip to content

Commit

Permalink
linear_solver: format .cs
Browse files Browse the repository at this point in the history
  • Loading branch information
Mizux committed Jul 10, 2023
1 parent e1311d6 commit 555b86a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions ortools/linear_solver/csharp/LinearExpr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public override double SolutionValue()
{
return expr_.SolutionValue() * coeff_;
}

private LinearExpr expr_;
private double coeff_;
}
Expand Down Expand Up @@ -223,7 +223,7 @@ public override double DoVisit(Dictionary<Variable, double> coefficients, double
return 0.0;
}
}

public override double SolutionValue()
{
return expr_.SolutionValue() + coeff_;
Expand Down
9 changes: 5 additions & 4 deletions ortools/linear_solver/csharp/LinearSolverTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -446,16 +446,17 @@ static void testSetHintAndSolverGetters()
[Fact]
static void Given_a_LinearExpr_and_a_solution_When_SolutionValue_is_called_then_the_result_is_correct()
{
Console.WriteLine(nameof(Given_a_LinearExpr_and_a_solution_When_SolutionValue_is_called_then_the_result_is_correct));
Console.WriteLine(
nameof(Given_a_LinearExpr_and_a_solution_When_SolutionValue_is_called_then_the_result_is_correct));
Solver solver = Solver.CreateSolver("glop");
// x, y and z are fixed; we don't want to test the solver here.
Variable x = solver.MakeIntVar(3, 3, "x");
Variable y = solver.MakeIntVar(4, 4, "y");
Variable z = solver.MakeIntVar(5, 5, "z");

LinearExpr part1 = x * 2; // 6
LinearExpr part2 = y * 3 + z + 4; // 21
LinearExpr objective = part1 + part2; // 27
LinearExpr part1 = x * 2; // 6
LinearExpr part2 = y * 3 + z + 4; // 21
LinearExpr objective = part1 + part2; // 27
LinearExpr anew = new();
solver.Maximize(objective);
solver.Solve();
Expand Down

0 comments on commit 555b86a

Please sign in to comment.