[R] GLPK API

yoooooo magno_yu at ml.com
Tue Jul 17 20:04:47 CEST 2007


Hi all, let's say I have:

lp = lpx_create_prob()
lpx_set_obj_dir(lp, LPX_MIN)
lpx_add_cols(lp, 3)
lpx_add_rows(lp, 2)
lpx_set_obj_coef(lp, 1, 100)
lpx_set_obj_coef(lp, 2, 200)
lpx_set_obj_coef(lp, 3, 300)
lpx_set_mat_row(lp, 1, 3, c(1, 2, 3), c(3, 2,1))
lpx_set_row_name(lp, 1, "c1")
lpx_set_row_bnds(lp, 1, LPX_LO, 100, 0)
print(lpx_get_mat_row(lp, 1))
lpx_write_cpxlp(lp, "hello")

> less hello
\* Problem: Unknown *\

Minimize
 obj: + 100 x_1 + 200 x_2 + 300 x_3

Subject To
 c1: + x_3 + 2 x_2 + 3 x_1 >= 100

Bounds
 x_1 = 0
 x_2 = 0
 x_3 = 0

End

But if I do in R, print(lpx_get_mat_row(lp, 1))

$n
[1] 3
$ind
[1] 3 2
$val
[1] 1 2

Is there a reason why I'm missing the 1st index and its constraint value in
get_mat_row? 

Thanks!
-- 
View this message in context: http://www.nabble.com/GLPK-API-tf4098577.html#a11654799
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list