Tabnine Logo
HardSoftScore.getHardScore
Code IndexAdd Tabnine to your IDE (free)

How to use
getHardScore
method
in
org.optaplanner.core.api.score.buildin.hardsoft.HardSoftScore

Best Java code snippets using org.optaplanner.core.api.score.buildin.hardsoft.HardSoftScore.getHardScore (Showing top 14 results out of 315)

origin: kiegroup/optaplanner

@Override
public int compare(Score s1, Score s2) {
  HardSoftScore score1 = (HardSoftScore) s1;
  HardSoftScore score2 = (HardSoftScore) s2;
  long score1Side = (long) score1.getHardScore() * (long) hardWeight + (long) score1.getSoftScore();
  long score2Side = (long) score2.getHardScore() * (long) hardWeight + (long) score2.getSoftScore();
  return score1Side < score2Side ? -1 : (score1Side == score2Side ? 0 : 1);
}
origin: kiegroup/optaplanner

@Override
public int compareTo(HardSoftScore other) {
  // A direct implementation (instead of CompareToBuilder) to avoid dependencies
  if (initScore != other.getInitScore()) {
    return initScore < other.getInitScore() ? -1 : 1;
  } else if (hardScore != other.getHardScore()) {
    return hardScore < other.getHardScore() ? -1 : 1;
  } else {
    return Integer.compare(softScore, other.getSoftScore());
  }
}
origin: kiegroup/optaplanner

@Override
public boolean equals(Object o) {
  // A direct implementation (instead of EqualsBuilder) to avoid dependencies
  if (this == o) {
    return true;
  } else if (o instanceof HardSoftScore) {
    HardSoftScore other = (HardSoftScore) o;
    return initScore == other.getInitScore()
        && hardScore == other.getHardScore()
        && softScore == other.getSoftScore();
  } else {
    return false;
  }
}
origin: kiegroup/optaplanner

@Override
public HardSoftScore buildOptimisticBound(InitializingScoreTrend initializingScoreTrend, HardSoftScore score) {
  InitializingScoreTrendLevel[] trendLevels = initializingScoreTrend.getTrendLevels();
  return HardSoftScore.ofUninitialized(0,
      trendLevels[0] == InitializingScoreTrendLevel.ONLY_DOWN ? score.getHardScore() : Integer.MAX_VALUE,
      trendLevels[1] == InitializingScoreTrendLevel.ONLY_DOWN ? score.getSoftScore() : Integer.MAX_VALUE);
}
origin: kiegroup/optaplanner

@Override
public HardSoftScore buildPessimisticBound(InitializingScoreTrend initializingScoreTrend, HardSoftScore score) {
  InitializingScoreTrendLevel[] trendLevels = initializingScoreTrend.getTrendLevels();
  return HardSoftScore.ofUninitialized(0,
      trendLevels[0] == InitializingScoreTrendLevel.ONLY_UP ? score.getHardScore() : Integer.MIN_VALUE,
      trendLevels[1] == InitializingScoreTrendLevel.ONLY_UP ? score.getSoftScore() : Integer.MIN_VALUE);
}
origin: kiegroup/optaplanner

@Override
public void configureConstraintWeight(Rule rule, HardSoftScore constraintWeight) {
  super.configureConstraintWeight(rule, constraintWeight);
  BiConsumer<RuleContext, Integer> matchExecutor;
  if (constraintWeight.equals(HardSoftScore.ZERO)) {
    matchExecutor = (RuleContext kcontext, Integer matchWeight) -> {};
  } else if (constraintWeight.getSoftScore() == 0) {
    matchExecutor = (RuleContext kcontext, Integer matchWeight)
        -> addHardConstraintMatch(kcontext, constraintWeight.getHardScore() * matchWeight);
  } else if (constraintWeight.getHardScore() == 0) {
    matchExecutor = (RuleContext kcontext, Integer matchWeight)
        -> addSoftConstraintMatch(kcontext, constraintWeight.getSoftScore() * matchWeight);
  } else {
    matchExecutor = (RuleContext kcontext, Integer matchWeight)
        -> addMultiConstraintMatch(kcontext,
        constraintWeight.getHardScore() * matchWeight,
        constraintWeight.getSoftScore() * matchWeight);
  }
  matchExecutorByNumberMap.put(rule, matchExecutor);
  matchExecutorByScoreMap.put(rule, (RuleContext kcontext,
      HardSoftScore weightMultiplier) -> addMultiConstraintMatch(kcontext,
      constraintWeight.getHardScore() * weightMultiplier.getHardScore(),
      constraintWeight.getSoftScore() * weightMultiplier.getSoftScore()));
}
origin: kiegroup/optaplanner

@Override
public HardSoftScore add(HardSoftScore augment) {
  return new HardSoftScore(
      initScore + augment.getInitScore(),
      hardScore + augment.getHardScore(),
      softScore + augment.getSoftScore());
}
origin: kiegroup/optaplanner

@Override
public HardSoftScore subtract(HardSoftScore subtrahend) {
  return new HardSoftScore(
      initScore - subtrahend.getInitScore(),
      hardScore - subtrahend.getHardScore(),
      softScore - subtrahend.getSoftScore());
}
origin: kiegroup/optaplanner

@Test
public void buildOptimisticBoundOnlyDown() {
  HardSoftScoreDefinition scoreDefinition = new HardSoftScoreDefinition();
  HardSoftScore optimisticBound = scoreDefinition.buildOptimisticBound(
      InitializingScoreTrend.buildUniformTrend(InitializingScoreTrendLevel.ONLY_DOWN, 2),
      HardSoftScore.of(-1, -2));
  assertEquals(0, optimisticBound.getInitScore());
  assertEquals(-1, optimisticBound.getHardScore());
  assertEquals(-2, optimisticBound.getSoftScore());
}
origin: kiegroup/optaplanner

@Test
public void serializeAndDeserialize() {
  PlannerTestUtils.serializeAndDeserializeWithAll(
      HardSoftScore.of(-12, 3400),
      output -> {
        assertEquals(0, output.getInitScore());
        assertEquals(-12, output.getHardScore());
        assertEquals(3400, output.getSoftScore());
      }
  );
  PlannerTestUtils.serializeAndDeserializeWithAll(
      HardSoftScore.ofUninitialized(-7, -12, 3400),
      output -> {
        assertEquals(-7, output.getInitScore());
        assertEquals(-12, output.getHardScore());
        assertEquals(3400, output.getSoftScore());
      }
  );
}
origin: kiegroup/optaplanner

@Test
public void buildOptimisticBoundOnlyUp() {
  HardSoftScoreDefinition scoreDefinition = new HardSoftScoreDefinition();
  HardSoftScore optimisticBound = scoreDefinition.buildOptimisticBound(
      InitializingScoreTrend.buildUniformTrend(InitializingScoreTrendLevel.ONLY_UP, 2),
      HardSoftScore.of(-1, -2));
  assertEquals(0, optimisticBound.getInitScore());
  assertEquals(Integer.MAX_VALUE, optimisticBound.getHardScore());
  assertEquals(Integer.MAX_VALUE, optimisticBound.getSoftScore());
}
origin: kiegroup/optaplanner

@Test
public void buildPessimisticBoundOnlyUp() {
  HardSoftScoreDefinition scoreDefinition = new HardSoftScoreDefinition();
  HardSoftScore pessimisticBound = scoreDefinition.buildPessimisticBound(
      InitializingScoreTrend.buildUniformTrend(InitializingScoreTrendLevel.ONLY_UP, 2),
      HardSoftScore.of(-1, -2));
  assertEquals(0, pessimisticBound.getInitScore());
  assertEquals(-1, pessimisticBound.getHardScore());
  assertEquals(-2, pessimisticBound.getSoftScore());
}
origin: kiegroup/optaplanner

@Test
public void buildPessimisticBoundOnlyDown() {
  HardSoftScoreDefinition scoreDefinition = new HardSoftScoreDefinition();
  HardSoftScore pessimisticBound = scoreDefinition.buildPessimisticBound(
      InitializingScoreTrend.buildUniformTrend(InitializingScoreTrendLevel.ONLY_DOWN, 2),
      HardSoftScore.of(-1, -2));
  assertEquals(0, pessimisticBound.getInitScore());
  assertEquals(Integer.MIN_VALUE, pessimisticBound.getHardScore());
  assertEquals(Integer.MIN_VALUE, pessimisticBound.getSoftScore());
}
origin: kiegroup/droolsjbpm-integration

@Test
public void testMarshallHardSoftScore() {
  HardSoftScore score = HardSoftScore.valueOf(10, 20);
  HardSoftScore result = marshallUnmarshallScore(score);
  assertNotNull(result);
  assertEquals(10, result.getHardScore());
  assertEquals(20, result.getSoftScore());
}
org.optaplanner.core.api.score.buildin.hardsoftHardSoftScoregetHardScore

Javadoc

The total of the broken negative hard constraints and fulfilled positive hard constraints. Their weight is included in the total. The hard score is usually a negative number because most use cases only have negative constraints.

Popular methods of HardSoftScore

  • of
  • ofUninitialized
  • parseScore
  • getSoftScore
  • getInitScore
  • ofSoft
  • toString
  • <init>
  • add
  • assertNoInitScore
  • buildShortString
  • divide
  • buildShortString,
  • divide,
  • equals,
  • getInitPrefix,
  • isFeasible,
  • multiply,
  • negate,
  • ofHard,
  • parseInitScore

Popular in Java

  • Making http post requests using okhttp
  • compareTo (BigDecimal)
  • setRequestProperty (URLConnection)
  • putExtra (Intent)
  • InputStreamReader (java.io)
    A class for turning a byte stream into a character stream. Data read from the source input stream is
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now