Пример #1
0
  @Override
  protected void performIteration() {

    QuadraticSolver tmpSolver = this.buildIterationSolver(false);

    Optimisation.Result tmpResult = tmpSolver.solve();

    if (tmpResult.getState().isFeasible()) {

      this.extractSolution(tmpSolver);

      this.setState(State.OPTIMAL);

    } else {

      tmpSolver = this.buildIterationSolver(true);
      tmpResult = tmpSolver.solve();

      if (tmpResult.getState().isFeasible()) {

        this.extractSolution(tmpSolver);

        this.setState(State.OPTIMAL);

      } else {

        this.resetX();
        this.setState(State.INFEASIBLE);
      }
    }
  }
Пример #2
0
  private void extractSolution(final QuadraticSolver aSolver) {

    final MatrixStore<Double> tmpSolutionX = aSolver.getSolutionX();

    final int tmpCountVariables = this.countVariables();
    final int tmpCountEqualityConstraints = this.countEqualityConstraints();

    for (int i = 0; i < tmpCountVariables; i++) {
      this.setX(i, tmpSolutionX.doubleValue(i));
    }

    for (int i = 0; i < tmpCountEqualityConstraints; i++) {
      this.setLE(i, tmpSolutionX.doubleValue(tmpCountVariables + i));
    }
  }
Пример #3
0
    Builder(final ExpressionsBasedModel aModel) {

      super(aModel);

      QuadraticSolver.copy(aModel, this);
    }