help-glpk
[Top][All Lists]
Advanced

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

Re: [Help-glpk] using about GLPK


From: Leandro Barcelos
Subject: Re: [Help-glpk] using about GLPK
Date: Sat, 2 Jun 2007 12:49:43 -0300

Hello Ivkai,

You should use integer statement on variables declaration

The solution is 14.

But if you have not integers parameters in your objective function, you can't say that's z will be integer. In this case, add an integer variable and a constraint witch tells the new variable is equals to you objective function definition.

#problem.mod

#variables
var x1 >= 0, integer;
var x2 >= 0, integer;
# var x3 >= 0, integer;
#objective
maximize z: 3*x1 + 2*x2;
#constraints
s.t. firstCondition: 2*x1 + 3*x2 <= 14;
s.t. secondCondition: 2*x1 + x2 <= 9;
# s.t. thirdCondition: x3 = 3*x1 + 2*x2;
end;


On 6/2/07, lvkai < address@hidden> wrote:
hello,

how are you?

I want to know how to solve the IP (not normal LP problem,but the problem whose result is Integer)?

I have made the model as follow:



#problem.mod

#variables
var x1 >= 0;
var x2 >= 0;
#objective
maximize z: 3*x1 + 2*x2;
#constraints
s.t. firstCondition: 2*x1 + 3*x2 <= 14;
s.t. secondCondition: 2*x1 + x2 <= 9;
end;



but when I type :glpsol -m problem.mod -o result



the final result is 14.75 but not a interger

can you help me?

thank you!





°Ù Íò Íæ ŒÒ Í¬ Íæ µÄ ÀÖ Ô°£¬ÈË Æø ±¬ ·¢ µÄ ÃÎ »Ã Î÷ ÓΠ 
_______________________________________________
Help-glpk mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/help-glpk





--
Leandro B. Barcelos
reply via email to

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