Skip to content

Commit

Permalink
investment: rename classes InvestmentAllocation* to Investment*
Browse files Browse the repository at this point in the history
  • Loading branch information
ge0ffrey committed Jun 9, 2015
1 parent d40c504 commit 993df58
Show file tree
Hide file tree
Showing 16 changed files with 81 additions and 84 deletions.
@@ -1,4 +1,4 @@
<InvestmentAllocationSolution id="1"> <InvestmentSolution id="1">
<id>0</id> <id>0</id>
<parametrization id="2"> <parametrization id="2">
<id>0</id> <id>0</id>
Expand Down Expand Up @@ -224,4 +224,4 @@
<assetClass reference="14"/> <assetClass reference="14"/>
</AssetClassAllocation> </AssetClassAllocation>
</assetClassAllocationList> </assetClassAllocationList>
</InvestmentAllocationSolution> </InvestmentSolution>
Expand Up @@ -19,28 +19,27 @@
import org.optaplanner.core.api.solver.Solver; import org.optaplanner.core.api.solver.Solver;
import org.optaplanner.core.api.solver.SolverFactory; import org.optaplanner.core.api.solver.SolverFactory;
import org.optaplanner.examples.common.app.CommonApp; import org.optaplanner.examples.common.app.CommonApp;
import org.optaplanner.examples.common.persistence.AbstractSolutionExporter;
import org.optaplanner.examples.common.persistence.AbstractSolutionImporter; import org.optaplanner.examples.common.persistence.AbstractSolutionImporter;
import org.optaplanner.examples.common.persistence.SolutionDao; import org.optaplanner.examples.common.persistence.SolutionDao;
import org.optaplanner.examples.common.swingui.SolutionPanel; import org.optaplanner.examples.common.swingui.SolutionPanel;
import org.optaplanner.examples.investmentallocation.persistence.InvestmentAllocationDao; import org.optaplanner.examples.investmentallocation.persistence.InvestmentDao;
import org.optaplanner.examples.investmentallocation.persistence.InvestmentAllocationImporter; import org.optaplanner.examples.investmentallocation.persistence.InvestmentImporter;
import org.optaplanner.examples.investmentallocation.swingui.InvestmentAllocationPanel; import org.optaplanner.examples.investmentallocation.swingui.InvestmentPanel;


public class InvestmentAllocationApp extends CommonApp { public class InvestmentApp extends CommonApp {


public static final String SOLVER_CONFIG public static final String SOLVER_CONFIG
= "org/optaplanner/examples/investmentallocation/solver/investmentAllocationSolverConfig.xml"; = "org/optaplanner/examples/investmentallocation/solver/investmentSolverConfig.xml";


public static void main(String[] args) { public static void main(String[] args) {
prepareSwingEnvironment(); prepareSwingEnvironment();
new InvestmentAllocationApp().init(); new InvestmentApp().init();
} }


public InvestmentAllocationApp() { public InvestmentApp() {
super("Investment asset class allocation", super("Investment asset class allocation",
"Decide the percentage of the investor's budget to invest in each asset class.", "Decide the percentage of the investor's budget to invest in each asset class.",
InvestmentAllocationPanel.LOGO_PATH); InvestmentPanel.LOGO_PATH);
} }


@Override @Override
Expand All @@ -51,17 +50,17 @@ protected Solver createSolver() {


@Override @Override
protected SolutionPanel createSolutionPanel() { protected SolutionPanel createSolutionPanel() {
return new InvestmentAllocationPanel(); return new InvestmentPanel();
} }


@Override @Override
protected SolutionDao createSolutionDao() { protected SolutionDao createSolutionDao() {
return new InvestmentAllocationDao(); return new InvestmentDao();
} }


@Override @Override
protected AbstractSolutionImporter createSolutionImporter() { protected AbstractSolutionImporter createSolutionImporter() {
return new InvestmentAllocationImporter(); return new InvestmentImporter();
} }


} }
Expand Up @@ -20,7 +20,7 @@


import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamAlias;
import org.optaplanner.examples.common.domain.AbstractPersistable; import org.optaplanner.examples.common.domain.AbstractPersistable;
import org.optaplanner.examples.investmentallocation.domain.util.InvestmentAllocationNumericUtil; import org.optaplanner.examples.investmentallocation.domain.util.InvestmentNumericUtil;


@XStreamAlias("AssetClass") @XStreamAlias("AssetClass")
public class AssetClass extends AbstractPersistable { public class AssetClass extends AbstractPersistable {
Expand Down Expand Up @@ -68,16 +68,16 @@ public void setCorrelationMillisMap(Map<AssetClass, Long> correlationMillisMap)
// ************************************************************************ // ************************************************************************


public String getExpectedReturnLabel() { public String getExpectedReturnLabel() {
return InvestmentAllocationNumericUtil.formatMillisAsPercentage(expectedReturnMillis); return InvestmentNumericUtil.formatMillisAsPercentage(expectedReturnMillis);
} }


public String getStandardDeviationRiskLabel() { public String getStandardDeviationRiskLabel() {
return InvestmentAllocationNumericUtil.formatMillisAsPercentage(standardDeviationRiskMillis); return InvestmentNumericUtil.formatMillisAsPercentage(standardDeviationRiskMillis);
} }


public String getCorrelationLabel(AssetClass other) { public String getCorrelationLabel(AssetClass other) {
long correlationMillis = correlationMillisMap.get(other); long correlationMillis = correlationMillisMap.get(other);
return InvestmentAllocationNumericUtil.formatMillisAsNumber(correlationMillis); return InvestmentNumericUtil.formatMillisAsNumber(correlationMillis);
} }


@Override @Override
Expand Down
Expand Up @@ -20,7 +20,7 @@
import org.optaplanner.core.api.domain.entity.PlanningEntity; import org.optaplanner.core.api.domain.entity.PlanningEntity;
import org.optaplanner.core.api.domain.variable.PlanningVariable; import org.optaplanner.core.api.domain.variable.PlanningVariable;
import org.optaplanner.examples.common.domain.AbstractPersistable; import org.optaplanner.examples.common.domain.AbstractPersistable;
import org.optaplanner.examples.investmentallocation.domain.util.InvestmentAllocationNumericUtil; import org.optaplanner.examples.investmentallocation.domain.util.InvestmentNumericUtil;


@PlanningEntity() @PlanningEntity()
@XStreamAlias("AssetClassAllocation") @XStreamAlias("AssetClassAllocation")
Expand Down Expand Up @@ -81,7 +81,7 @@ public String getQuantityLabel() {
if (quantityMillis == null) { if (quantityMillis == null) {
return ""; return "";
} }
return InvestmentAllocationNumericUtil.formatMillisAsPercentage(quantityMillis); return InvestmentNumericUtil.formatMillisAsPercentage(quantityMillis);
} }


public String getLabel() { public String getLabel() {
Expand Down
Expand Up @@ -31,12 +31,12 @@
import org.optaplanner.core.api.score.buildin.hardsoftlong.HardSoftLongScore; import org.optaplanner.core.api.score.buildin.hardsoftlong.HardSoftLongScore;
import org.optaplanner.core.impl.score.buildin.hardsoftlong.HardSoftLongScoreDefinition; import org.optaplanner.core.impl.score.buildin.hardsoftlong.HardSoftLongScoreDefinition;
import org.optaplanner.examples.common.domain.AbstractPersistable; import org.optaplanner.examples.common.domain.AbstractPersistable;
import org.optaplanner.examples.investmentallocation.domain.util.InvestmentAllocationNumericUtil; import org.optaplanner.examples.investmentallocation.domain.util.InvestmentNumericUtil;
import org.optaplanner.persistence.xstream.impl.score.XStreamScoreConverter; import org.optaplanner.persistence.xstream.impl.score.XStreamScoreConverter;


@PlanningSolution @PlanningSolution
@XStreamAlias("InvestmentAllocationSolution") @XStreamAlias("InvestmentSolution")
public class InvestmentAllocationSolution extends AbstractPersistable implements Solution<HardSoftLongScore> { public class InvestmentSolution extends AbstractPersistable implements Solution<HardSoftLongScore> {


private InvestmentParametrization parametrization; private InvestmentParametrization parametrization;
private List<AssetClass> assetClassList; private List<AssetClass> assetClassList;
Expand Down Expand Up @@ -85,7 +85,7 @@ public void setScore(HardSoftLongScore score) {


@ValueRangeProvider(id = "quantityMillisRange") @ValueRangeProvider(id = "quantityMillisRange")
public CountableValueRange<Long> getQuantityMillisRange() { public CountableValueRange<Long> getQuantityMillisRange() {
return ValueRangeFactory.createLongValueRange(0L, InvestmentAllocationNumericUtil.MAXIMUM_QUANTITY_MILLIS + 1L); return ValueRangeFactory.createLongValueRange(0L, InvestmentNumericUtil.MAXIMUM_QUANTITY_MILLIS + 1L);
} }


public Collection<? extends Object> getProblemFacts() { public Collection<? extends Object> getProblemFacts() {
Expand Down
Expand Up @@ -20,7 +20,7 @@
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.NumberFormat; import java.text.NumberFormat;


public class InvestmentAllocationNumericUtil { public class InvestmentNumericUtil {


public static final long MAXIMUM_QUANTITY_MILLIS = 1000L; public static final long MAXIMUM_QUANTITY_MILLIS = 1000L;


Expand Down Expand Up @@ -48,7 +48,7 @@ public static String formatMicrosAsPercentage(long micros) {
return MILLIS_PERCENT_FORMAT.format(value); return MILLIS_PERCENT_FORMAT.format(value);
} }


private InvestmentAllocationNumericUtil() { private InvestmentNumericUtil() {
} }


} }
Expand Up @@ -17,12 +17,12 @@
package org.optaplanner.examples.investmentallocation.persistence; package org.optaplanner.examples.investmentallocation.persistence;


import org.optaplanner.examples.common.persistence.XStreamSolutionDao; import org.optaplanner.examples.common.persistence.XStreamSolutionDao;
import org.optaplanner.examples.investmentallocation.domain.InvestmentAllocationSolution; import org.optaplanner.examples.investmentallocation.domain.InvestmentSolution;


public class InvestmentAllocationDao extends XStreamSolutionDao { public class InvestmentDao extends XStreamSolutionDao {


public InvestmentAllocationDao() { public InvestmentDao() {
super("investmentallocation", InvestmentAllocationSolution.class); super("investmentallocation", InvestmentSolution.class);
} }


} }
Expand Up @@ -28,23 +28,23 @@
import org.optaplanner.examples.common.persistence.AbstractTxtSolutionImporter; import org.optaplanner.examples.common.persistence.AbstractTxtSolutionImporter;
import org.optaplanner.examples.investmentallocation.domain.AssetClass; import org.optaplanner.examples.investmentallocation.domain.AssetClass;
import org.optaplanner.examples.investmentallocation.domain.AssetClassAllocation; import org.optaplanner.examples.investmentallocation.domain.AssetClassAllocation;
import org.optaplanner.examples.investmentallocation.domain.InvestmentAllocationSolution; import org.optaplanner.examples.investmentallocation.domain.InvestmentSolution;
import org.optaplanner.examples.investmentallocation.domain.InvestmentParametrization; import org.optaplanner.examples.investmentallocation.domain.InvestmentParametrization;


public class InvestmentAllocationImporter extends AbstractTxtSolutionImporter { public class InvestmentImporter extends AbstractTxtSolutionImporter {


private static final String INPUT_FILE_SUFFIX = "csv"; private static final String INPUT_FILE_SUFFIX = "csv";


public static void main(String[] args) { public static void main(String[] args) {
InvestmentAllocationImporter importer = new InvestmentAllocationImporter(); InvestmentImporter importer = new InvestmentImporter();
importer.convert("irrinki_1.csv", "irrinki_1.xml"); importer.convert("irrinki_1.csv", "irrinki_1.xml");
} }


public InvestmentAllocationImporter() { public InvestmentImporter() {
super(new InvestmentAllocationDao()); super(new InvestmentDao());
} }


public InvestmentAllocationImporter(boolean withoutDao) { public InvestmentImporter(boolean withoutDao) {
super(withoutDao); super(withoutDao);
} }


Expand All @@ -59,10 +59,10 @@ public TxtInputBuilder createTxtInputBuilder() {


public static class InvestmentAllocationInputBuilder extends TxtInputBuilder { public static class InvestmentAllocationInputBuilder extends TxtInputBuilder {


private InvestmentAllocationSolution solution; private InvestmentSolution solution;


public Solution readSolution() throws IOException { public Solution readSolution() throws IOException {
solution = new InvestmentAllocationSolution(); solution = new InvestmentSolution();
solution.setId(0L); solution.setId(0L);
readHeaders(); readHeaders();
readAssetClassList(); readAssetClassList();
Expand Down
Expand Up @@ -19,8 +19,6 @@
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.NavigableMap;
import java.util.Random; import java.util.Random;


import org.optaplanner.core.impl.heuristic.move.CompositeMove; import org.optaplanner.core.impl.heuristic.move.CompositeMove;
Expand All @@ -29,19 +27,19 @@
import org.optaplanner.core.impl.score.director.ScoreDirector; import org.optaplanner.core.impl.score.director.ScoreDirector;
import org.optaplanner.core.impl.solver.random.RandomUtils; import org.optaplanner.core.impl.solver.random.RandomUtils;
import org.optaplanner.examples.investmentallocation.domain.AssetClassAllocation; import org.optaplanner.examples.investmentallocation.domain.AssetClassAllocation;
import org.optaplanner.examples.investmentallocation.domain.InvestmentAllocationSolution; import org.optaplanner.examples.investmentallocation.domain.InvestmentSolution;
import org.optaplanner.examples.investmentallocation.domain.util.InvestmentAllocationNumericUtil; import org.optaplanner.examples.investmentallocation.domain.util.InvestmentNumericUtil;
import org.optaplanner.examples.investmentallocation.solver.move.InvestmentQuantityTransferMove; import org.optaplanner.examples.investmentallocation.solver.move.InvestmentQuantityTransferMove;


public class InvestmentBiQuantityTransferMoveIteratorFactory implements MoveIteratorFactory { public class InvestmentBiQuantityTransferMoveIteratorFactory implements MoveIteratorFactory {


@Override @Override
public long getSize(ScoreDirector scoreDirector) { public long getSize(ScoreDirector scoreDirector) {
InvestmentAllocationSolution solution = (InvestmentAllocationSolution) scoreDirector.getWorkingSolution(); InvestmentSolution solution = (InvestmentSolution) scoreDirector.getWorkingSolution();
int size = solution.getAssetClassAllocationList().size(); int size = solution.getAssetClassAllocationList().size();
// The MAXIMUM_QUANTITY_MILLIS accounts for all fromAllocations too // The MAXIMUM_QUANTITY_MILLIS accounts for all fromAllocations too
return InvestmentAllocationNumericUtil.MAXIMUM_QUANTITY_MILLIS return InvestmentNumericUtil.MAXIMUM_QUANTITY_MILLIS
* InvestmentAllocationNumericUtil.MAXIMUM_QUANTITY_MILLIS * InvestmentNumericUtil.MAXIMUM_QUANTITY_MILLIS
* (size - 1) * (size - 1); * (size - 1) * (size - 1);
} }


Expand All @@ -52,7 +50,7 @@ public Iterator<Move> createOriginalMoveIterator(ScoreDirector scoreDirector) {


@Override @Override
public Iterator<Move> createRandomMoveIterator(ScoreDirector scoreDirector, Random workingRandom) { public Iterator<Move> createRandomMoveIterator(ScoreDirector scoreDirector, Random workingRandom) {
InvestmentAllocationSolution solution = (InvestmentAllocationSolution) scoreDirector.getWorkingSolution(); InvestmentSolution solution = (InvestmentSolution) scoreDirector.getWorkingSolution();
List<AssetClassAllocation> allocationList = solution.getAssetClassAllocationList(); List<AssetClassAllocation> allocationList = solution.getAssetClassAllocationList();
List<AssetClassAllocation> nonEmptyAllocationList = new ArrayList<AssetClassAllocation>(allocationList); List<AssetClassAllocation> nonEmptyAllocationList = new ArrayList<AssetClassAllocation>(allocationList);
for (Iterator<AssetClassAllocation> it = nonEmptyAllocationList.iterator(); it.hasNext(); ) { for (Iterator<AssetClassAllocation> it = nonEmptyAllocationList.iterator(); it.hasNext(); ) {
Expand Down
Expand Up @@ -28,18 +28,18 @@
import org.optaplanner.core.impl.score.director.ScoreDirector; import org.optaplanner.core.impl.score.director.ScoreDirector;
import org.optaplanner.core.impl.solver.random.RandomUtils; import org.optaplanner.core.impl.solver.random.RandomUtils;
import org.optaplanner.examples.investmentallocation.domain.AssetClassAllocation; import org.optaplanner.examples.investmentallocation.domain.AssetClassAllocation;
import org.optaplanner.examples.investmentallocation.domain.InvestmentAllocationSolution; import org.optaplanner.examples.investmentallocation.domain.InvestmentSolution;
import org.optaplanner.examples.investmentallocation.domain.util.InvestmentAllocationNumericUtil; import org.optaplanner.examples.investmentallocation.domain.util.InvestmentNumericUtil;
import org.optaplanner.examples.investmentallocation.solver.move.InvestmentQuantityTransferMove; import org.optaplanner.examples.investmentallocation.solver.move.InvestmentQuantityTransferMove;


public class InvestmentQuantityTransferMoveIteratorFactory implements MoveIteratorFactory { public class InvestmentQuantityTransferMoveIteratorFactory implements MoveIteratorFactory {


@Override @Override
public long getSize(ScoreDirector scoreDirector) { public long getSize(ScoreDirector scoreDirector) {
InvestmentAllocationSolution solution = (InvestmentAllocationSolution) scoreDirector.getWorkingSolution(); InvestmentSolution solution = (InvestmentSolution) scoreDirector.getWorkingSolution();
int size = solution.getAssetClassAllocationList().size(); int size = solution.getAssetClassAllocationList().size();
// The MAXIMUM_QUANTITY_MILLIS accounts for all fromAllocations too // The MAXIMUM_QUANTITY_MILLIS accounts for all fromAllocations too
return InvestmentAllocationNumericUtil.MAXIMUM_QUANTITY_MILLIS * (size - 1); return InvestmentNumericUtil.MAXIMUM_QUANTITY_MILLIS * (size - 1);
} }


@Override @Override
Expand All @@ -49,7 +49,7 @@ public Iterator<Move> createOriginalMoveIterator(ScoreDirector scoreDirector) {


@Override @Override
public Iterator<Move> createRandomMoveIterator(ScoreDirector scoreDirector, Random workingRandom) { public Iterator<Move> createRandomMoveIterator(ScoreDirector scoreDirector, Random workingRandom) {
InvestmentAllocationSolution solution = (InvestmentAllocationSolution) scoreDirector.getWorkingSolution(); InvestmentSolution solution = (InvestmentSolution) scoreDirector.getWorkingSolution();
List<AssetClassAllocation> allocationList = solution.getAssetClassAllocationList(); List<AssetClassAllocation> allocationList = solution.getAssetClassAllocationList();
NavigableMap<Long, AssetClassAllocation> quantityMillisIncrementToAllocationMap = new TreeMap<Long, AssetClassAllocation>(); NavigableMap<Long, AssetClassAllocation> quantityMillisIncrementToAllocationMap = new TreeMap<Long, AssetClassAllocation>();
long quantityIncrementMillis = 0L; long quantityIncrementMillis = 0L;
Expand All @@ -60,10 +60,10 @@ public Iterator<Move> createRandomMoveIterator(ScoreDirector scoreDirector, Rand
quantityMillisIncrementToAllocationMap.put(quantityIncrementMillis, allocation); quantityMillisIncrementToAllocationMap.put(quantityIncrementMillis, allocation);
} }
} }
if (quantityIncrementMillis != InvestmentAllocationNumericUtil.MAXIMUM_QUANTITY_MILLIS) { if (quantityIncrementMillis != InvestmentNumericUtil.MAXIMUM_QUANTITY_MILLIS) {
throw new IllegalStateException("The quantityIncrementMillis (" + quantityIncrementMillis throw new IllegalStateException("The quantityIncrementMillis (" + quantityIncrementMillis
+ ") must always be total to MAXIMUM_QUANTITY_MILLIS (" + ") must always be total to MAXIMUM_QUANTITY_MILLIS ("
+ InvestmentAllocationNumericUtil.MAXIMUM_QUANTITY_MILLIS + ")."); + InvestmentNumericUtil.MAXIMUM_QUANTITY_MILLIS + ").");
} }
return new RandomInvestmentQuantityTransferMoveIterator(allocationList, return new RandomInvestmentQuantityTransferMoveIterator(allocationList,
quantityMillisIncrementToAllocationMap, workingRandom); quantityMillisIncrementToAllocationMap, workingRandom);
Expand All @@ -88,7 +88,7 @@ public boolean hasNext() {


public Move next() { public Move next() {
long transferMillis long transferMillis
= RandomUtils.nextLong(workingRandom, InvestmentAllocationNumericUtil.MAXIMUM_QUANTITY_MILLIS) + 1L; = RandomUtils.nextLong(workingRandom, InvestmentNumericUtil.MAXIMUM_QUANTITY_MILLIS) + 1L;
Map.Entry<Long, AssetClassAllocation> lowerEntry Map.Entry<Long, AssetClassAllocation> lowerEntry
= quantityMillisIncrementToAllocationMap.lowerEntry(transferMillis); = quantityMillisIncrementToAllocationMap.lowerEntry(transferMillis);
Map.Entry<Long, AssetClassAllocation> ceilingEntry = quantityMillisIncrementToAllocationMap Map.Entry<Long, AssetClassAllocation> ceilingEntry = quantityMillisIncrementToAllocationMap
Expand Down
Expand Up @@ -18,11 +18,11 @@


import org.optaplanner.core.api.score.buildin.hardsoftlong.HardSoftLongScore; import org.optaplanner.core.api.score.buildin.hardsoftlong.HardSoftLongScore;
import org.optaplanner.core.impl.score.director.easy.EasyScoreCalculator; import org.optaplanner.core.impl.score.director.easy.EasyScoreCalculator;
import org.optaplanner.examples.investmentallocation.domain.InvestmentAllocationSolution; import org.optaplanner.examples.investmentallocation.domain.InvestmentSolution;


public class InvestmentEasyScoreCalculator implements EasyScoreCalculator<InvestmentAllocationSolution> { public class InvestmentEasyScoreCalculator implements EasyScoreCalculator<InvestmentSolution> {


public HardSoftLongScore calculateScore(InvestmentAllocationSolution solution) { public HardSoftLongScore calculateScore(InvestmentSolution solution) {
long hardScore = 0L; long hardScore = 0L;
long softScore = 0L; long softScore = 0L;
long squaredFemtosMaximum = solution.getParametrization().calculateSquaredStandardDeviationFemtosMaximum(); long squaredFemtosMaximum = solution.getParametrization().calculateSquaredStandardDeviationFemtosMaximum();
Expand Down
Expand Up @@ -20,15 +20,15 @@
import org.optaplanner.core.api.score.buildin.hardsoftlong.HardSoftLongScore; import org.optaplanner.core.api.score.buildin.hardsoftlong.HardSoftLongScore;
import org.optaplanner.core.impl.score.director.incremental.AbstractIncrementalScoreCalculator; import org.optaplanner.core.impl.score.director.incremental.AbstractIncrementalScoreCalculator;
import org.optaplanner.examples.investmentallocation.domain.AssetClassAllocation; import org.optaplanner.examples.investmentallocation.domain.AssetClassAllocation;
import org.optaplanner.examples.investmentallocation.domain.InvestmentAllocationSolution; import org.optaplanner.examples.investmentallocation.domain.InvestmentSolution;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;


public class InvestmentIncrementalScoreCalculator extends AbstractIncrementalScoreCalculator<InvestmentAllocationSolution> { public class InvestmentIncrementalScoreCalculator extends AbstractIncrementalScoreCalculator<InvestmentSolution> {


protected final transient Logger logger = LoggerFactory.getLogger(getClass()); protected final transient Logger logger = LoggerFactory.getLogger(getClass());


private InvestmentAllocationSolution solution; private InvestmentSolution solution;


private long squaredStandardDeviationFemtosMaximum; private long squaredStandardDeviationFemtosMaximum;
private long squaredStandardDeviationFemtos; private long squaredStandardDeviationFemtos;
Expand All @@ -40,7 +40,7 @@ public class InvestmentIncrementalScoreCalculator extends AbstractIncrementalSco
// Lifecycle methods // Lifecycle methods
// ************************************************************************ // ************************************************************************


public void resetWorkingSolution(InvestmentAllocationSolution solution) { public void resetWorkingSolution(InvestmentSolution solution) {
this.solution = solution; this.solution = solution;
squaredStandardDeviationFemtosMaximum = solution.getParametrization() squaredStandardDeviationFemtosMaximum = solution.getParametrization()
.calculateSquaredStandardDeviationFemtosMaximum(); .calculateSquaredStandardDeviationFemtosMaximum();
Expand Down
Expand Up @@ -19,8 +19,8 @@
import org.optaplanner.core.impl.phase.custom.CustomPhaseCommand; import org.optaplanner.core.impl.phase.custom.CustomPhaseCommand;
import org.optaplanner.core.impl.score.director.ScoreDirector; import org.optaplanner.core.impl.score.director.ScoreDirector;
import org.optaplanner.examples.investmentallocation.domain.AssetClassAllocation; import org.optaplanner.examples.investmentallocation.domain.AssetClassAllocation;
import org.optaplanner.examples.investmentallocation.domain.InvestmentAllocationSolution; import org.optaplanner.examples.investmentallocation.domain.InvestmentSolution;
import org.optaplanner.examples.investmentallocation.domain.util.InvestmentAllocationNumericUtil; import org.optaplanner.examples.investmentallocation.domain.util.InvestmentNumericUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;


Expand All @@ -29,12 +29,12 @@ public class InvestmentAllocationSolutionInitializer implements CustomPhaseComma
protected final transient Logger logger = LoggerFactory.getLogger(getClass()); protected final transient Logger logger = LoggerFactory.getLogger(getClass());


public void changeWorkingSolution(ScoreDirector scoreDirector) { public void changeWorkingSolution(ScoreDirector scoreDirector) {
InvestmentAllocationSolution solution = (InvestmentAllocationSolution) scoreDirector.getWorkingSolution(); InvestmentSolution solution = (InvestmentSolution) scoreDirector.getWorkingSolution();
distributeQuantityEvenly(scoreDirector, solution); distributeQuantityEvenly(scoreDirector, solution);
} }


private void distributeQuantityEvenly(ScoreDirector scoreDirector, InvestmentAllocationSolution solution) { private void distributeQuantityEvenly(ScoreDirector scoreDirector, InvestmentSolution solution) {
long budget = InvestmentAllocationNumericUtil.MAXIMUM_QUANTITY_MILLIS; long budget = InvestmentNumericUtil.MAXIMUM_QUANTITY_MILLIS;
int size = solution.getAssetClassAllocationList().size(); int size = solution.getAssetClassAllocationList().size();
long budgetPerAllocation = budget / size; long budgetPerAllocation = budget / size;
long remainder = budget % size; long remainder = budget % size;
Expand Down

0 comments on commit 993df58

Please sign in to comment.