Skip to content

Commit

Permalink
LinearSolver.Builder
Browse files Browse the repository at this point in the history
  • Loading branch information
apete committed Jul 30, 2024
1 parent 5af4ef4 commit 23ffcce
Show file tree
Hide file tree
Showing 8 changed files with 215 additions and 204 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ Added / Changed / Deprecated / Fixed / Removed / Security

> Corresponds to changes in the `develop` branch since the last release
### Changed

#### org.ojalgo.optimisation

- The new LP solver implementation is now the default alternative.
- The two classes `LinearSolver.GeneralBuilder` and `LinearSolver.StandardBuilder` are replaced by a common `LinearSolver.Builder`. Consequently the methods `newGeneralBuilder()` and `newStandardBuilder()` are deprecated and replaced by `newBuilder()`.

## [54.0.0] – 2024-06-06

### Added
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/ojalgo/optimisation/convex/ConvexSolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -201,15 +201,15 @@ public Builder quadratic(final Access2D<?> factors) {
/**
* Disregard the objective function (set it to zero) and form the dual LP.
*/
public LinearSolver.GeneralBuilder toFeasibilityChecker() {
public LinearSolver.Builder toFeasibilityChecker() {

MatrixStore<Double> mtrxAE = this.getAE();
MatrixStore<Double> mtrxBE = this.getBE();

MatrixStore<Double> mtrxAI = this.getAI();
MatrixStore<Double> mtrxBI = this.getBI();

LinearSolver.GeneralBuilder retVal = LinearSolver.newGeneralBuilder();
LinearSolver.Builder retVal = LinearSolver.newBuilder();

int nbEqus = this.countEqualityConstraints();
int nbIneq = this.countInequalityConstraints();
Expand Down Expand Up @@ -253,15 +253,15 @@ public LinearSolver.GeneralBuilder toFeasibilityChecker() {
*
* @see #toLinearApproximation(Access1D)
*/
public LinearSolver.GeneralBuilder toLinearApproximation() {
public LinearSolver.Builder toLinearApproximation() {
return this.toLinearApproximation(ArrayR064.make(this.countVariables()));
}

/**
* Linearise the objective function (at the specified point) and duplicate all variables to handle the
* (potential) positive and negative parts separately.
*/
public LinearSolver.GeneralBuilder toLinearApproximation(final Access1D<Double> point) {
public LinearSolver.Builder toLinearApproximation(final Access1D<Double> point) {

MatrixStore<Double> mtrxC = this.getObjective().toFirstOrderApproximation(point).getLinearFactors(false);

Expand All @@ -271,7 +271,7 @@ public LinearSolver.GeneralBuilder toLinearApproximation(final Access1D<Double>
MatrixStore<Double> mtrxAI = this.getAI();
MatrixStore<Double> mtrxBI = this.getBI();

LinearSolver.GeneralBuilder retVal = LinearSolver.newGeneralBuilder();
LinearSolver.Builder retVal = LinearSolver.newBuilder();

retVal.objective(mtrxC.below(mtrxC.negate()));

Expand Down
12 changes: 7 additions & 5 deletions src/main/java/org/ojalgo/optimisation/integer/IntegerSolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,12 @@ public Result solve(final Result kickStarter) {

this.resetIterationsCount();

ExpressionsBasedModel cutModel = myIntegerModel.snapshot();
NodeSolver cutSolver = cutModel.prepare(NodeSolver::new);
Result cutResult = cutSolver.solve();
cutSolver.generateCuts(strategy, myIntegerModel);
if (strategy.cutting) {
ExpressionsBasedModel cutModel = myIntegerModel.snapshot();
NodeSolver cutSolver = cutModel.prepare(NodeSolver::new);
Result cutResult = cutSolver.solve();
cutSolver.generateCuts(strategy, myIntegerModel);
}

NodeKey rootNode = new NodeKey(myIntegerModel);
ExpressionsBasedModel rootModel = myIntegerModel.snapshot();
Expand Down Expand Up @@ -520,7 +522,7 @@ boolean compute(final NodeKey nodeKey, final NodeSolver nodeSolver, final RingLo
IntegerSolver.flush(nodePrinter, myIntegerModel.options.logger_appender);
}

if (strategy.cutting && nodeKey.sequence % 10L == 0L) {
if (strategy.cutting && nodeKey.sequence % 100L == 0L) {
double displacement = nodeKey.getMinimumDisplacement(branchIntegerIndex, variableValue);
if (strategy.isCutRatherThanBranch(displacement, myBestResultSoFar != null)) {
if (nodeSolver.generateCuts(strategy, nodeKey)) {
Expand Down
Loading

0 comments on commit 23ffcce

Please sign in to comment.