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

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

Best Java code snippets using org.optaplanner.core.api.score.buildin.hardsoft.HardSoftScore.getSoftScore (Showing top 16 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 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

@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

softConstraintsPenaltyElement.setText(Integer.toString(nurseRoster.getScore().getSoftScore()));
solutionElement.addContent(softConstraintsPenaltyElement);
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 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 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: org.optaplanner/optaplanner-examples

softConstraintsPenaltyElement.setText(Integer.toString(nurseRoster.getScore().getSoftScore()));
solutionElement.addContent(softConstraintsPenaltyElement);
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.hardsoftHardSoftScoregetSoftScore

Javadoc

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

In a normal score comparison, the soft score is irrelevant if the 2 scores don't have the same hard score.

Popular methods of HardSoftScore

  • of
  • ofUninitialized
  • parseScore
  • getHardScore
    The total of the broken negative hard constraints and fulfilled positive hard constraints. Their wei
  • getInitScore
  • ofSoft
  • toString
  • <init>
  • add
  • assertNoInitScore
  • buildShortString
  • divide
  • buildShortString,
  • divide,
  • equals,
  • getInitPrefix,
  • isFeasible,
  • multiply,
  • negate,
  • ofHard,
  • parseInitScore

Popular in Java

  • Reading from database using SQL prepared statement
  • notifyDataSetChanged (ArrayAdapter)
  • onRequestPermissionsResult (Fragment)
  • setScale (BigDecimal)
  • OutputStream (java.io)
    A writable sink for bytes.Most clients will use output streams that write data to the file system (
  • Socket (java.net)
    Provides a client-side TCP socket.
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • SortedSet (java.util)
    SortedSet is a Set which iterates over its elements in a sorted order. The order is determined eithe
  • ImageIO (javax.imageio)
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
  • From CI to AI: The AI layer in your organization
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