Skip to content

Commit 42931ec

Browse files
committed
optional activation
1 parent c02e0da commit 42931ec

File tree

3 files changed

+26
-24
lines changed

3 files changed

+26
-24
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
<properties>
5252
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
5353
<version.java>11</version.java>
54-
<version.org.junit.jupiter>5.12.2</version.org.junit.jupiter>
54+
<version.org.junit.jupiter>5.13.0</version.org.junit.jupiter>
5555
<version.org.openjdk.jmh>1.37</version.org.openjdk.jmh>
5656
</properties>
5757
<dependencies>

src/main/java/org/ojalgo/optimisation/convex/ActiveSetSolver.java

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ protected boolean initialise(final Result kickStarter) {
345345
}
346346

347347
if (state.isFeasible()) {
348-
this.resetActivator();
348+
this.resetActivator(!options.convex().isExtendedPrecision());
349349
} else {
350350
this.getSolutionX().fillAll(ZERO);
351351
}
@@ -400,8 +400,8 @@ protected boolean needsAnotherIteration() {
400400
}
401401

402402
/**
403-
* Find the minimum (largest negative) lagrange multiplier - for the active inequalities - to
404-
* potentially deactivate.
403+
* Find the minimum (largest negative) lagrange multiplier - for the active inequalities - to potentially
404+
* deactivate.
405405
*/
406406
protected int suggestConstraintToExclude() {
407407

@@ -468,8 +468,7 @@ protected int suggestConstraintToExclude() {
468468

469469
/**
470470
* Find minimum (largest negative) slack - for the inactive inequalities - to potentially activate.
471-
* Negative slack means the constraint is violated. Need to make sure it is enforced by activating
472-
* it.
471+
* Negative slack means the constraint is violated. Need to make sure it is enforced by activating it.
473472
*/
474473
protected int suggestConstraintToInclude() {
475474
return this.getConstraintToInclude();
@@ -652,35 +651,38 @@ void handleIterationResults(final boolean solved, final R064Store iterX, final i
652651

653652
}
654653

655-
void resetActivator() {
654+
void resetActivator(final boolean activate) {
656655

657656
myActivator.excludeAll();
658657
myExcluded = null;
659658
myIncluded = null;
660659

661-
int nbInes = this.countInequalityConstraints();
662-
int nbEqus = this.countEqualityConstraints();
663-
int nbVars = this.countVariables();
660+
if (activate) {
664661

665-
int maxToInclude = nbVars - nbEqus;
662+
int nbInes = this.countInequalityConstraints();
663+
int nbEqus = this.countEqualityConstraints();
664+
int nbVars = this.countVariables();
666665

667-
if (this.isLogDebug() && maxToInclude < 0) {
668-
this.log("Redundant contraints!");
669-
}
666+
int maxToInclude = nbVars - nbEqus;
670667

671-
if (nbInes > 0 && maxToInclude > 0) {
668+
if (this.isLogDebug() && maxToInclude < 0) {
669+
this.log("Redundant contraints!");
670+
}
672671

673-
MatrixStore<Double> ineqSlack = this.getSlackI();
672+
if (nbInes > 0 && maxToInclude > 0) {
674673

675-
for (int i = 0; i < nbInes; i++) {
674+
MatrixStore<Double> ineqSlack = this.getSlackI();
676675

677-
double slack = ineqSlack.doubleValue(i);
676+
for (int i = 0; i < nbInes; i++) {
678677

679-
if (slack >= ZERO && ACC.isZero(slack) && this.countIncluded() < maxToInclude) {
680-
if (this.isLogDebug()) {
681-
this.log("Will inlcude ineq {} with slack={}", i, slack);
678+
double slack = ineqSlack.doubleValue(i);
679+
680+
if (slack >= ZERO && ACC.isZero(slack) && this.countIncluded() < maxToInclude) {
681+
if (this.isLogDebug()) {
682+
this.log("Will inlcude ineq {} with slack={}", i, slack);
683+
}
684+
this.include(i);
682685
}
683-
this.include(i);
684686
}
685687
}
686688
}

src/main/java/org/ojalgo/optimisation/convex/IterativeASS.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,9 +304,9 @@ void addConstraint(final int constrIndex, final SparseArray<Double> constrBody,
304304
}
305305

306306
@Override
307-
void resetActivator() {
307+
void resetActivator(boolean activate) {
308308

309-
super.resetActivator();
309+
super.resetActivator(activate);
310310

311311
int nbEqus = this.countEqualityConstraints();
312312
int nbVars = this.countVariables();

0 commit comments

Comments
 (0)