Hello, the API allows to create the LP problem in your example.
I would suggest you first bring you problem into the normal form: - constant term on the right hand side - variable terms on the left hand side. Then you may create the problem row by row or column by column. To create the problem row by row, start with creating the problem: glp_create_prob glp_set_prob_name Create the columns (variables) glp_add_cols glp_set_col_name glp_set_col_kind glp_set_col_bnds Create the rows (constraints) glp_add_rows glp_set_row_name glp_set_row_bnds glp_set_mat_row Create the objective glp_set_obj_name glp_set_obj_dir glp_set_obj_coef Start the solver glp_init_smcp glp_simplex Retrieve the result glp_get_num_cols glp_get_col_name glp_get_col_prim Delete the problem glp_delete_prob You can find a Java example here: http://www.nabble.com/file/p22711936/GLPKtest001.java GLPKtest001.java Best regards Xypron rainly wrote: > > Hello,I am new to the glpk package and i needed some help: > I have an objective function and a set of constraints > but I dont know how to pogram it with glpk.I want to > use the set of api routines the glpk provides. > I have read the example in the manual but > still the example is so simple compared to my > equations. Following is just a very small example and I know how to write > an > input file to solve the problem. Please let me know if I can do it > using API. > > objective function > min : a1+a2+a3+a4+a5+a6+2.5 b1+2.5 b2+2.5 b3+ 2.5 > b4+2.5 b5+2.5 b6 > > Constraints: > > x_1_1 + x_1_2 +x_1_3 = 151; > x_2_1 + x_2_2 +x_2_3 = 401; > x_3_1 + x_3_2 +x_3_3 = 51; > x_4_1 + x_4_2 +x_4_3 = 101; > x_5_1 + x_5_2 +x_5_3 = 51; > x_6_1 + x_6_2 +x_6_3 = 31; > > x_1_1 + x_2_2 + x_3_2+x_4_2+x_5_2 <= 63 a1+252 b1 > x_1_2 + x_2_1 + x_3_3+x_4_2+x_6_2 <= 63 a2+252 b2 > x_1_3 + x_2_3 + x_3_1+x_5_2+x_6_2 <= 63 a3+252 b3 > x_1_2 + x_2_2 + x_4_1+x_5_3+x_6_3 <= 63 a4+252 b4 > x_1_3 + x_3_2 + x_4_3+x_5_1+x_6_3 <= 63 a5+252 b5 > x_2_3 + x_3_3 + x_4_3+x_5_3+x_6_1 <= 63 a6+252 b6 > > Thanks in advance, > -- View this message in context: http://www.nabble.com/Can-I-use-API-to-form-non-standard-LP-problem--tp22710374p22711936.html Sent from the Gnu - GLPK - Help mailing list archive at Nabble.com. _______________________________________________ Help-glpk mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-glpk
