コード例 #1
0
ファイル: P20150809.java プロジェクト: VincentBiragnet/ojAlgo
 public static void main(final String[] args) {
   System.out.println();
   P20150809.attempt5(true, false);
   System.out.println();
   P20150809.attempt5(true, true);
   System.out.println();
   P20150809.attempt5(false, true);
   System.out.println();
   P20150809.attempt5(false, false);
 }
コード例 #2
0
ファイル: P20150809.java プロジェクト: VincentBiragnet/ojAlgo
  static void attempt5(final boolean identity, final boolean addDummyConstraints) {

    final ConvexSolver cs = P20150809.buildModel(identity, addDummyConstraints);

    try {
      final Optimisation.Result solution = cs.solve();
      if ((solution.getState() == Optimisation.State.DISTINCT)
          || (solution.getState() == Optimisation.State.APPROXIMATE)
          || (solution.getState() == Optimisation.State.OPTIMAL)) {
        final double[] pt = new double[4];
        for (int i = 0; i < pt.length; i++) {
          pt[i] = solution.doubleValue(i);
        }

        System.out.println("Objective " + solution.getValue());
        for (int ii = 0; ii < 4; ii++) {
          System.out.println("x[" + ii + "] = " + solution.doubleValue(ii));
        }
      } else {
        System.out.println("Failure State = " + solution.getState().name());
      }

    } catch (final Exception e) {
      System.out.println(e);
    }
  }