- Mail actions: [ respond to this message ] [ mail a new topic ]
- Contemporary messages sorted: [ by date ] [ by thread ] [ by subject ] [ by author ] [ by messages with attachments ]

From: Kim Lai <kim73327_at_...6...>

Date: Fri, 25 Apr 2008 08:54:35 +0800

Date: Fri, 25 Apr 2008 08:54:35 +0800

hi, I found a strange behavior about the big-M constraints in eplex.Two code snippet with the same logic result in different opt solution. For code 1: => [A1, A2, A3] = [0, 0.2, 0] , Cost = 2.5 For code 2: => [A1, A2, A3] = [ 0, 0.1, 2.6], Cost = 3.9 --------- code 1----------------- :- lib(eplex). solve(Vars, Cost) :- model(Vars, Obj), eplex_solver_setup(min(Obj)), eplex_solve(Cost). model(Vars, Obj) :- Vars = [A1, A2, A3 ], Vars $:: 0..inf, M = 10000000, B = [B1, B2], B :: 0..1, integers(B), Obj $>= A1 + 1.2, Obj $>= A2 + 2.3, Obj $>= A3 + 1.3, A2 - A1 $=< -2.2 + (1-B1)*M, A2 - A1 + B1*M $>= 0.1, A3 - A2 $=< -0.2 + B2*M, A3 - A2 + (1-B2)*M $>= 2.5. ------------code 2---------------------------------------- :- lib(eplex). solve(Vars, Cost) :- model(Vars, Obj), eplex_solver_setup(min(Obj)), eplex_solve(Cost). model(Vars, Obj) :- Vars = [A1, A2, A3 ], Vars $:: 0..inf, M = 10000000, B = [B1, B2], B :: 0..1, integers(B), Obj $>= A1 + 1.2, Obj $>= A2 + 2.3, Obj $>= A3 + 1.3, A2 - A1 $=< -2.2 + (1-B1)*M, A2 - A1 + B1*M $>= 0.1, A3 - A2 $=< -0.2 + (1-B2)*M, A3 - A2 + B2*M $>= 2.5. -------------------------------------------------------------------- Is there any thing that I misunderstand or need to set up ? ps. thanks for point out my wrong usage of "porting". It should be "embedded with C++" ? On Fri, Apr 25, 2008 at 7:26 AM, Kish Shen <kisshen_at_...5...> wrote: > Kim Lai wrote: > >> hi, your reply is a great help for me. thanks. >> I use lib(eplex) to reformulate my problem as follow. and it really got a >> solution. >> But after I port the following code to C++. I'm getting trouble with ""How >> to extract the variables result"". >> A result like this "A2{0.0 .. 1.7976931348623157e+308 _at_ >> 1.1999999992549422}" >> I'd like to extract A2=1.199 = 1.2 >> But it's not even a string... >> in C++: I usually use "EC_word(Vars[i]).is_double(&d) == EC_succeed" >> to get a double or long int .....And this didn't work.. >> ------------eclipse code------------------------ >> > > Your specific problem is that when a problem is solved by eplex, the > problem variables are not instantiated. This allows you to modify the > problem and resolve it. eplex_var_get/3 allows you to extract the solution > value from the variable, e.g. for the variable A2 above, > > .... > eplex_var_get(A2, solution, A2Sol), > > > will instantiate A2Sol to the solution value of A2 > > So you should exract the solution values, and pass these to C++. > > A more general point: I am not quite sure what you mean exactly by `porting > to C++' - you seem to want to pass solution values from a ECLiPSe program to > C++. This is probably the best way to use ECLiPSe as a constraint solver > when you are using ECLiPSe with other languages -- but I would not call this > `porting', but interfacing. > > Cheers, > > Kish > -- ....Best Regards by Kim Lai, 賴廣甫 Welcome to visit http://kimklai.blogspot.comReceived on Thu Apr 24 2008 - 17:54:37 CEST

*
This archive was generated by hypermail 2.3.0
: Sat Jul 20 2019 - 18:14:38 CEST
*