I ran this example from the tutorial and got a different but equally optimal solution. ----- eplex_10.ecl % Transportation Problem Example. % From http://eclipseclp.org/doc/tutorial/tutorial118.html#toc117 % entitled 16.3.3 Getting more solution information from the solver % Run in this way: main2(Cost, Vars). /* ?- main2(Cost, Vars). Cost = 710.0 Vars = [16.0, 5.0, 0.0, 0.0, 25.0, 15.0, 34.0, 0.0, 0.0, 0.0, 0.0, 10.0] Yes (0.00s cpu) The tutorial has this as a solution: Cost = 710.0 Vars = [0.0, 21.0, 0.0, 16.0, 9.0, 15.0, 34.0, 0.0, 0.0, 0.0, 0.0, 10.0] */ :- lib(eplex). :- eplex_instance(prob). % a. declare an eplex instance main2(Cost, Vars) :- % b. create the problem variables and set their range Vars = [A1,A2,A3,B1,B2,B3,C1,C2,C3,D1,D2,D3], prob: (Vars $:: 0.0..1.0Inf), % c. post the constraints for the problem to the eplex instance prob: (A1 + A2 + A3 $= 21), prob: (B1 + B2 + B3 $= 40), prob: (C1 + C2 + C3 $= 34), prob: (D1 + D2 + D3 $= 10), prob: (A1 + B1 + C1 + D1 $=< 50), prob: (A2 + B2 + C2 + D2 $=< 30), prob: (A3 + B3 + C3 + D3 $=< 40), % d. set up the external solver with the objective function prob: eplex_solver_setup(min( 10*A1 + 7*A2 + 200*A3 + 8*B1 + 5*B2 + 10*B3 + 5*C1 + 5*C2 + 8*C3 + 9*D1 + 3*D2 + 7*D3)), %------------------------------- End of Modelling code prob: eplex_solve(Cost), % e. Solve problem using external solver (foreach(V, Vars) do % f. set the problem variables to their solution values prob: eplex_var_get(V, typed_solution, V) ). ----- This is a quote from the same section of the tutorial: "Note that, in general, an MP problem can have many optimal solutions, i.e. different solutions which give the optimal value for the objective function." The tutorial has one optimal solution. My recent run got another. How do I get the same optimal solution as the tutorial?Received on Wed Oct 30 2013 - 21:27:29 CET
This archive was generated by hypermail 2.3.0 : Wed Sep 25 2024 - 15:13:21 CEST