Skip to content

Commit

Permalink
countUniqueStrategies
Browse files Browse the repository at this point in the history
  • Loading branch information
apete committed Nov 10, 2024
1 parent f3b0c6a commit e443567
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/main/java/org/ojalgo/optimisation/integer/IntegerStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,27 @@ public ConfigurableStrategy addPriorityDefinitions(final Comparator<NodeKey>...
return new ConfigurableStrategy(myParallelism, totalDefinitions, myIntegralityTolerance, myGapTolerance, myFactory, myGMICutConfiguration);
}

@Override
public int countUniqueStrategies() {
return myPriorityDefinitions.length;
}

@Override
public NumberContext getGapTolerance() {
return myGapTolerance;
}

@Override
public GMICutConfiguration getGMICutConfiguration() {
return myGMICutConfiguration;
}

@Override
public NumberContext getIntegralityTolerance() {
return myIntegralityTolerance;
}

@Override
public List<Comparator<NodeKey>> getWorkerPriorities() {
int parallelism = myParallelism.getAsInt();
List<Comparator<NodeKey>> retVal = new ArrayList<>(parallelism);
Expand All @@ -99,6 +108,7 @@ public List<Comparator<NodeKey>> getWorkerPriorities() {
return retVal;
}

@Override
public ModelStrategy newModelStrategy(final ExpressionsBasedModel model) {
return myFactory.apply(model, this);
}
Expand Down Expand Up @@ -191,6 +201,8 @@ static ConfigurableStrategy newConfigurable() {
return new ConfigurableStrategy(Parallelism.CORES.require(4), definitions, integrality, gap, DefaultStrategy::new, new GMICutConfiguration());
}

int countUniqueStrategies();

/**
* The MIP gap is the difference between the best integer solution found so far and a node's relaxed
* non-integer solution. The relative MIP gap is that difference divided by the optimal value
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/org/ojalgo/optimisation/integer/ModelStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ protected double toComparable(final int idx, final double displacement, final bo

protected ModelStrategy(final ExpressionsBasedModel model, final IntegerStrategy strategy) {

myOptimisationSense = (model.getOptimisationSense() != Optimisation.Sense.MAX) ? Sense.MIN : Sense.MAX;
myOptimisationSense = model.getOptimisationSense() != Optimisation.Sense.MAX ? Sense.MIN : Sense.MAX;

myStrategy = strategy;

Expand All @@ -211,22 +211,32 @@ protected ModelStrategy(final ExpressionsBasedModel model, final IntegerStrategy
myWorkerPriorities = strategy.getWorkerPriorities();
}

@Override
public int countUniqueStrategies() {
return myStrategy.countUniqueStrategies();
}

@Override
public NumberContext getGapTolerance() {
return myStrategy.getGapTolerance();
}

@Override
public GMICutConfiguration getGMICutConfiguration() {
return myStrategy.getGMICutConfiguration();
}

@Override
public NumberContext getIntegralityTolerance() {
return myStrategy.getIntegralityTolerance();
}

@Override
public List<Comparator<NodeKey>> getWorkerPriorities() {
return myWorkerPriorities;
}

@Override
public ModelStrategy newModelStrategy(final ExpressionsBasedModel model) {
return myStrategy.newModelStrategy(model);
}
Expand Down

0 comments on commit e443567

Please sign in to comment.