help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-glpk] implementing constraints in Scala


From: name name
Subject: Re: [Help-glpk] implementing constraints in Scala
Date: Sun, 31 Jul 2011 16:07:01 +0200

thank you very much I have some more question

there is a problem I got no solution and i dont knew why.

Could you tell me in which function(s) is the problem?

the contraints I did as you told me. I change only GLP_UP; FX


startModelBuilding(nbRows : Int, nbCols : Int){
lp = GLPK.glp_create_prob()
        GLPK.glp_add_cols(lp, nbCols)
}

      def setBounds(colId : Int, low : Double, up : Double) {
        GLPK.glp_set_col_bnds(lp, colId+1, GLPKConstants.GLP_DB, low, up)
      }
     
      def setUnboundUpperBound(colId : Int) {
      GLPK.glp_set_col_bnds(lp, colId+1, GLPKConstants.GLP_LO, 0,1000)
      }

    def addObjective(coef : Array[Double], col : Array[Int], minMode : Boolean = true) {
        GLPK.glp_set_obj_name(lp, "objective");       
        GLPK.glp_set_obj_dir(lp, if (minMode) GLPKConstants.GLP_MIN else GLPKConstants.GLP_MAX)
        for (i <- 0 to col.size-1) {
          GLPK.glp_set_obj_coef(lp, i,coef(i))
        }
    }

    def solveModel() : Int = {
      println("solveModel");
        val iocp = new glp_iocp();
        GLPK.glp_init_iocp(iocp);
        iocp.setPresolve(
GLPKConstants.GLP_ON);
        val ret = GLPK.glp_intopt(lp, iocp);

        if (ret == 0) {
          sol = Array.tabulate(nbCols)(col => GLPK.glp_mip_col_val(lp,col +1))
          objectiveValue = GLPK.glp_mip_obj_val(lp)

          ret
        } else {
            System.out.println("The problem could not be solved");
            ret

reply via email to

[Prev in Thread] Current Thread [Next in Thread]