Skip to content

Commit 4995536

Browse files
committed
Update ExpressionsBasedModel.java
1 parent 381eee7 commit 4995536

File tree

1 file changed

+39
-4
lines changed

1 file changed

+39
-4
lines changed

Diff for: src/main/java/org/ojalgo/optimisation/ExpressionsBasedModel.java

+39-4
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ public String toString() {
188188
* {@link ExpressionsBasedModel.Integration#toModelState(org.ojalgo.optimisation.Optimisation.Result, ExpressionsBasedModel)}.
189189
* </ol>
190190
*/
191-
public static interface EntityMap extends ProblemStructure {
191+
public interface EntityMap extends ProblemStructure {
192192

193193
/**
194194
* The number of variables, in the solver, that directly correspond to a model variable. (Not slack or
@@ -346,7 +346,7 @@ protected final void setSwitch(final ExpressionsBasedModel model, final Integrat
346346
* @see ExpressionsBasedModel.Integration#setSwitch(ExpressionsBasedModel, IntegrationProperty, boolean)
347347
* @see ExpressionsBasedModel.Integration#isSwitch(ExpressionsBasedModel, IntegrationProperty)
348348
*/
349-
public static enum IntegrationProperty {
349+
public enum IntegrationProperty {
350350

351351
/**
352352
* Any integration that can switch between Java and native code solvers.
@@ -482,6 +482,37 @@ static final class DefaultIntermediate extends IntermediateSolver {
482482

483483
}
484484

485+
static final class IntegrationWrapper extends ExpressionsBasedModel.Integration<Optimisation.Solver> {
486+
487+
private final Optimisation.Integration<ExpressionsBasedModel, ?> myDelegate;
488+
489+
IntegrationWrapper(final Optimisation.Integration<ExpressionsBasedModel, ?> delegate) {
490+
super();
491+
myDelegate = delegate;
492+
}
493+
494+
@Override
495+
public Solver build(final ExpressionsBasedModel model) {
496+
return myDelegate.build(model);
497+
}
498+
499+
@Override
500+
public boolean isCapable(final ExpressionsBasedModel model) {
501+
return myDelegate.isCapable(model);
502+
}
503+
504+
@Override
505+
public Result toModelState(final Result solverState, final ExpressionsBasedModel model) {
506+
return myDelegate.toModelState(solverState, model);
507+
}
508+
509+
@Override
510+
public Result toSolverState(final Result modelState, final ExpressionsBasedModel model) {
511+
return myDelegate.toSolverState(modelState, model);
512+
}
513+
514+
}
515+
485516
static abstract class Simplifier<ME extends ModelEntity<?>, S extends Simplifier<?, ?>> implements Comparable<S> {
486517

487518
private final int myExecutionOrder;
@@ -699,8 +730,12 @@ void update(final ArrayList<Variable> variables) {
699730
/**
700731
* Add an integration for a solver that will be used rather than the built-in solvers
701732
*/
702-
public static boolean addIntegration(final Integration<?> integration) {
703-
return INTEGRATIONS.add(integration);
733+
public static boolean addIntegration(final Optimisation.Integration<ExpressionsBasedModel, ?> integration) {
734+
if (integration instanceof ExpressionsBasedModel.Integration<?>) {
735+
return INTEGRATIONS.add((ExpressionsBasedModel.Integration<?>) integration);
736+
} else {
737+
return INTEGRATIONS.add(new IntegrationWrapper(integration));
738+
}
704739
}
705740

706741
public static boolean addPresolver(final Presolver presolver) {

0 commit comments

Comments
 (0)