From: Thorsten Winterer <thorsten_winterer_at_...126...>

Date: Thu, 10 Oct 2013 17:32:00 +0200

Date: Thu, 10 Oct 2013 17:32:00 +0200

The help text for eplex:integers/1 states that [u]nlike integers/1 constraints from other solvers, the variables are not constrained to be integer type at the ECLiPSe level. However, when a typed_solution is retrieved (e.g. via eplex_var_get/3), this will be rounded to the nearest integer. I.e., you have to retrieve the integer value from the MIP solver yourself if you are not using optimize/2: mip_example(X,Y,Cost) :- eplex_instance(my_instance), my_instance: (X+Y $>= 3), my_instance: (X-Y $= 0), my_instance: integers([X]), % This is a mixed integer problem. my_instance: eplex_solver_setup(min(X)), my_instance: eplex_solve(Cost), % retrieve typed solution my_instance: eplex_get(vars, Vars), my_instance: eplex_get(typed_solution, Vals), Vars = Vals. ?- mip_example(X, Y, C). X = 2 Y = 2.0 C = 2.0 Yes (0.02s cpu) Cheers, Thorsten Am 10.10.2013 17:04, schrieb Paul Cannongeyser: > I ran this example. The results were unexpected. > > ----- eplex_9.ecl > % Run in this way: mip_example(X,Y,Cost). > % From http://eclipseclp.org/doc/libman/libman060.html#toc67 entitled > 10.2.6 Examples > /* > Results: > ?- mip_example(X, Y, Cost). > X = X{-1.7976931348623157e+308 .. 1.7976931348623157e+308 @ 2.0} > Y = Y{-1.7976931348623157e+308 .. 1.7976931348623157e+308 @ 2.0} > Cost = 2.0 > Yes (0.00s cpu) > > No integer variables - nothing to do (in orange letters) > > */ > > :- lib(eplex). > :- eplex_instance(my_instance). > > mip_example(X,Y,Cost) :- > my_instance: (X+Y $>= 3), > my_instance: (X-Y $= 0), > my_instance: integers([X]), % This is a mixed integer problem. > my_instance: eplex_solver_setup(min(X)), > my_instance: eplex_solve(Cost). > ----- > > However, I was able to run a similar example without any warnings and > the result showed as an integer, rather > than a decimal. > > ----- eplex_3.ecl > % Run in this way: top(X,Y,Cost). > % From http://eclipseclp.org/reports/Workshop/eplex.ppt entitled The > EPLEX Library > /* > Results: > ?- top(X, Y, Cost). > X = 2 <<<<<<====== X is printed as an integer, 2, not a > decimal, 2.0. (Nicely done.) > Y = 2.0 > Cost = 2.0 > Yes (0.00s cpu) > > */ > > :-lib(eplex). > > top(X,Y,Cost) :- > X+Y $>=3, > X-Y $= 0, > integers([X]), % This is a mixed integer problem. > optimize(min(X),Cost). > ----- > > Is the result in my first program run (i.e., eplex_9.ecl, at the top > of this email) the correct behavior or did I do something wrong? > > > ------------------------------------------------------------------------------ > October Webinars: Code for Performance > Free Intel webinars can help you accelerate application performance. > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from > the latest Intel processors and coprocessors. See abstracts and register > > http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk > > > _______________________________________________ > ECLiPSe-CLP-Users mailing list > ECLiPSe-CLP-Users_at_lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/eclipse-clp-usersReceived on Thu Oct 10 2013 - 15:32:09 CEST

*
This archive was generated by hypermail 2.2.0
: Mon Jul 09 2018 - 02:05:30 CEST
*