Skip to content

Commit

Permalink
solver builder
Browse files Browse the repository at this point in the history
  • Loading branch information
apete committed Feb 15, 2024
1 parent 958c728 commit 9fd6a95
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 55 deletions.
40 changes: 2 additions & 38 deletions src/main/java/org/ojalgo/optimisation/convex/ConvexSolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,36 +94,10 @@ public abstract class ConvexSolver extends GenericSolver {

public static final class Builder extends GenericSolver.Builder<ConvexSolver.Builder, ConvexSolver> {

/**
* @deprecated v50 Use {@link ConvexSolver#newBuilder()} instead.
*/
@Deprecated
public Builder() {
Builder() {
super();
}

/**
* @deprecated v50 Use {@link ConvexSolver#newBuilder()} instead.
*/
@Deprecated
public Builder(final MatrixStore<Double> C) {

super();

this.objective(C);
}

/**
* @deprecated v50 Use {@link ConvexSolver#newBuilder()} instead.
*/
@Deprecated
public Builder(final MatrixStore<Double> Q, final MatrixStore<Double> C) {

super();

this.objective(Q, C);
}

Builder(final int nbVariables) {
super();
this.setNumberOfVariables(nbVariables);
Expand All @@ -141,7 +115,7 @@ public Builder(final MatrixStore<Double> Q, final MatrixStore<Double> C) {
if (matrices[2] != null) {
this.objective(matrices[2], matrices[3]);
} else if (matrices[3] != null) {
this.objective(matrices[3]);
this.objective(null, matrices[3]);
}
}

Expand Down Expand Up @@ -215,16 +189,6 @@ public Builder objective(final int row, final int col, final double value) {
return this;
}

/**
* @deprecated v50 Use {@link #objective(MatrixStore, MatrixStore)} instead, or build a
* {@link LinearSolver}.
*/
@Deprecated
public Builder objective(final MatrixStore<?> mtrxC) {
this.setObjective(BasePrimitiveSolver.toObjectiveFunction(null, mtrxC));
return this;
}

public Builder objective(final MatrixStore<?> mtrxQ, final MatrixStore<?> mtrxC) {
this.setObjective(BasePrimitiveSolver.toObjectiveFunction(mtrxQ, mtrxC));
return this;
Expand Down
15 changes: 1 addition & 14 deletions src/main/java/org/ojalgo/optimisation/linear/LinearSolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -231,24 +231,11 @@ protected int getIndexInSolver(final ExpressionsBasedModel model, final Variable
*/
public static final class StandardBuilder extends LinearSolver.Builder<StandardBuilder> {

/**
* @deprecated v50 Use {@link LinearSolver#newBuilder()} instead.
*/
@Deprecated
public StandardBuilder() {
StandardBuilder() {
super();
}

/**
* @deprecated v50 Use {@link LinearSolver#newBuilder()} instead.
*/
@Deprecated
public StandardBuilder(final MatrixStore<Double> mtrxC) {

super();

this.objective(mtrxC);
}

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public void testP20110614() {

MatrixStore<Double> tmpX = Primitive64Store.FACTORY.rows(new double[][] { { 0.0 }, { 0.5217391304347826 }, { 0.4782608695652173 } });

ConvexSolver.Builder tmpBuilder = new ConvexSolver.Builder(tmpQ, tmpC).equalities(tmpAE, tmpBE).inequalities(tmpAI, tmpBI);
ConvexSolver.Builder tmpBuilder = ConvexSolver.newBuilder().objective(tmpQ, tmpC).equalities(tmpAE, tmpBE).inequalities(tmpAI, tmpBI);

ConvexSolver tmpSolver = tmpBuilder.build();
// tmpSolver.options.debug(ConvexSolver.class);
Expand All @@ -163,7 +163,7 @@ public void testP20110614() {
tmpAI = Primitive64Store.FACTORY.rows(new double[][] { { 1.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }, { 0.0, 0.0, 1.0 } });
tmpBI = Primitive64Store.FACTORY.rows(new double[][] { { 1.0 }, { 1.0 }, { 1.0 } });

tmpBuilder = new ConvexSolver.Builder(tmpQ, tmpC).equalities(tmpAE, tmpBE).inequalities(tmpAI, tmpBI);
tmpBuilder = ConvexSolver.newBuilder().objective(tmpQ, tmpC).equalities(tmpAE, tmpBE).inequalities(tmpAI, tmpBI);
tmpSolver = tmpBuilder.build();
tmpResult = tmpSolver.solve();

Expand All @@ -176,7 +176,7 @@ public void testP20110614() {
.rows(new double[][] { { -1.0, 0.0, 0.0 }, { 0.0, -1.0, 0.0 }, { 0.0, 0.0, -1.0 }, { 1.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }, { 0.0, 0.0, 1.0 } });
tmpBI = Primitive64Store.FACTORY.rows(new double[][] { { 0.0 }, { 0.0 }, { 0.0 }, { 1.0 }, { 1.0 }, { 1.0 } });

tmpBuilder = new ConvexSolver.Builder(tmpQ, tmpC).equalities(tmpAE, tmpBE).inequalities(tmpAI, tmpBI);
tmpBuilder = ConvexSolver.newBuilder().objective(tmpQ, tmpC).equalities(tmpAE, tmpBE).inequalities(tmpAI, tmpBI);
tmpSolver = tmpBuilder.build();
tmpResult = tmpSolver.solve();

Expand Down

0 comments on commit 9fd6a95

Please sign in to comment.