Exemplo n.º 1
0
Arquivo: MF.java Projeto: nflip/aads
  public static LpSolve conv2MinCostLP(
      int[][] cs, int[][] cost, int[][] map, int s, int t, double objective)
      throws LpSolveException {
    int E = cntE(cs);
    int V = cntV(cs);

    LpSolve solver = conv2LPBase(cs, s, t, map, V, E);

    solver.strAddConstraint(objStr(cs, E, map, s), LpSolve.EQ, objective);

    solver.setMinim();
    solver.setLpName("Converted min cost flow");

    int[] constr = new int[E];
    for (int from = 0; from < cs.length; from++) {
      for (int to = 0; to < cs.length; to++) {
        if (cs[from][to] != 0) {
          constr[map[from][to]] = cost[from][to];
        }
      }
    }

    solver.strSetObjFn(constrStr(constr));
    return solver;
  }
Exemplo n.º 2
0
Arquivo: MF.java Projeto: nflip/aads
  public static LpSolve conv2LP(int[][] cs, int s, int t, int[][] map) throws LpSolveException {
    int E = cntE(cs);
    int V = cntV(cs);

    LpSolve solver = conv2LPBase(cs, s, t, map, V, E);
    // GENERATE objective function

    solver.strSetObjFn(objStr(cs, E, map, s));

    // other options
    solver.setMaxim();
    solver.setLpName("Converted max flow");
    //	solver.setVerbose(3);

    return solver;
  }