Beispiel #1
0
  /**
   * Optimizes the objective while also optimizing the sum of absolute values of fluxes.
   *
   * @return the GLPK status of the solver
   */
  private synchronized int runOptimizeSumAbsoluteValuesFluxes() {
    // First run - deal with objective flux.
    int ret = -1;
    if (objStyle == FBAModel.MIN_OBJECTIVE_MAX_TOTAL
        || objStyle == FBAModel.MIN_OBJECTIVE_MIN_TOTAL) GLPK.glp_set_obj_dir(lp, GLPK.GLP_MIN);
    else GLPK.glp_set_obj_dir(lp, GLPK.GLP_MAX);

    if (objStyle == FBAModel.MAX_OBJECTIVE_MIN_TOTAL
        || objStyle == FBAModel.MIN_OBJECTIVE_MIN_TOTAL) GLPK.glp_set_obj_dir(lpMSA, GLPK.GLP_MIN);
    else GLPK.glp_set_obj_dir(lpMSA, GLPK.GLP_MAX);

    // setup done.

    int status = -1; // GLPK.glp_simplex(lp, param);
    simParam.setPresolve(GLPK.GLP_OFF);
    switch (glpkSolverMethod) {
      case SIMPLEX_METHOD:
        status = GLPK.glp_simplex(lp, simParam);
        break;
      default:
        status = GLPK.glp_interior(lp, intParam);
        break;
    }

    if (status != 0) return status;

    // now, fetch the objective solution from lp, and fix it as the
    // upper and lower bounds to lpMSA
    double sol = GLPK.glp_get_obj_val(lp);
    GLPK.glp_set_col_bnds(lpMSA, objReaction, GLPK.GLP_FX, sol, sol);

    //		ret = GLPK.glp_simplex(lpMSA, param);
    switch (glpkSolverMethod) {
      case SIMPLEX_METHOD:
        ret = GLPK.glp_simplex(lpMSA, simParam);
        break;
      default:
        ret = GLPK.glp_interior(lpMSA, intParam);
        break;
    }
    return ret;
  }
Beispiel #2
0
  /**
   * Internally initializes and resets the parameters used by GLPK. If you want to set specific GLPK
   * parameters, you'll need to call a specialized function. //TODO make this possible...
   */
  public void setParameters() {
    simParam = new glp_smcp();
    GLPK.glp_init_smcp(simParam);
    intParam = new glp_iptcp();
    GLPK.glp_init_iptcp(intParam);

    GLPK.glp_init_smcp(simParam);
    GLPK.glp_init_iptcp(intParam);

    // assume lpsolver == 1, and the rest = default, for now.

    // remap of control parameters for simplex method
    simParam.setMsg_lev(GLPKConstants.GLP_MSG_OFF);
    intParam.setMsg_lev(GLPKConstants.GLP_MSG_OFF);

    // simplex method: primal/dual
    switch (GLPIntParam[2]) {
      case 0:
        simParam.setMeth(GLPKConstants.GLP_PRIMAL);
        break;
      case 1:
        simParam.setMeth(GLPKConstants.GLP_DUAL);
        break;
      case 2:
        simParam.setMeth(GLPKConstants.GLP_DUALP);
        break;
      default:
        break;
    }
    // pricing technique
    if (GLPIntParam[3] == 0) simParam.setPricing(GLPKConstants.GLP_PT_STD);
    else simParam.setPricing(GLPKConstants.GLP_PT_PSE);
    // ratio test

    if (GLPIntParam[20] == 0) simParam.setR_test(GLPKConstants.GLP_RT_STD);
    else simParam.setR_test(GLPKConstants.GLP_RT_HAR);

    // tolerances
    simParam.setTol_bnd(GLPRealParam[1]); // primal feasible tolerance
    simParam.setTol_dj(GLPRealParam[2]); // dual feasible tolerance
    simParam.setTol_piv(GLPRealParam[3]); // pivot tolerance
    simParam.setObj_ll(GLPRealParam[4]); // lower limit
    simParam.setObj_ul(GLPRealParam[5]); // upper limit

    // iteration limit
    if (GLPIntParam[5] == -1) simParam.setIt_lim(Integer.MAX_VALUE);
    else simParam.setIt_lim(GLPIntParam[5]);

    // time limit
    if (GLPRealParam[6] == -1) simParam.setTm_lim(Integer.MAX_VALUE);
    else simParam.setTm_lim((int) GLPRealParam[6]);
    simParam.setOut_frq(GLPIntParam[7]); // output frequency
    simParam.setOut_dly((int) GLPRealParam[7]); // output delay

    // presolver
    if (GLPIntParam[16] != 0) simParam.setPresolve(GLPK.GLP_ON);
    else simParam.setPresolve(GLPK.GLP_OFF);
  }