help-glpk
[Top][All Lists]
Advanced

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

[Help-glpk] implementing contrants in Scala


From: name name
Subject: [Help-glpk] implementing contrants in Scala
Date: Thu, 28 Jul 2011 11:59:48 +0200

I would like to implment glpk in scala.

    def addConstraintLessEqual(coef : Array[Double], col : Array[Int], rhs : Double) {
 nbRows += 1   
        GLPK.glp_add_rows(lp, 1);
        GLPK.glp_set_row_name(lp, 1, "constraint"+nbRows);
        GLPK.glp_set_row_bnds(lp, 1, GLPKConstants.GLP_UP, rhs, 0)
        val ind = GLPK.new_intArray(col.size)
        for (i <- 1 to col.size) {
          GLPK.intArray_setitem(ind, i, col(i-1)+1);
        }
        val values = GLPK.new_doubleArray(col.size);
        for (i <- 1 to col.size) {
          GLPK.doubleArray_setitem(values, col(i-1)+1, coef(i-1));
        }
        GLPK.glp_set_mat_row(lp, nbRows, col.size, ind, values)       
        println("addConstraintLessEqual: end");
    }



could you tell me where is the problem ?


reply via email to

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