From: Seppe vanden Broucke <macuyiko_at_...6...>

Date: Fri, 09 Oct 2009 17:58:55 +0200

Date: Fri, 09 Oct 2009 17:58:55 +0200

Hello I've been trying to solve a certain problem with ECLiPSe. I'm almost finished writing the source, but I'm having a problem when calling minimize. The program looks like this: %================= snip ============== :-lib(ic). % :-lib(ic_global). :-lib(ic_search). :-lib(branch_and_bound). cost(1, 3, 1, 3.82). cost(1, 3, 2, 0.45). cost(1, 3, 4, 0.45). % ... solve(TripletNR, Triplets, Cost) :- dim(Triplets, [TripletNR,3]), SatNR is TripletNR*2, Triplets[1..TripletNR,1..3] :: 1..SatNR, % a list of constraints, which are working... % I now want to calculate the cost ( for(K,1,TripletNR), fromto(0,In,Out,Cost), param(Triplets) do My1 is Triplets[K,1], My2 is Triplets[K,2], My3 is Triplets[K,3], cost(My1, My2, My3, Mycost), Out is In+Mycost ), % minimize: minimize(labeling(Triplets), Cost). %================= snip ============== I've been using this as an example: http://www.hakank.org/ECLiPSe/assignment.ecl When I run my program with solve(2, Triplets, Cost)., the output is: ?- solve(2, Triplets, Cost). Triplets = []([](1, 3, 1), [](2, 4, 2)) Cost = 3.8699999999999997 Yes (0.02s cpu, solution 1, maybe more) Found a solution with cost 3.8699999999999997 Which is just the first labelled solution, pressing more (or using findall) just iterates all the possible solutions: Found a solution with cost 3.8699999999999997 Found a solution with cost 4.13 Found a solution with cost 0.56 Found a solution with cost 1.5899999999999999 ... Running the example gives the minimum solution and immediately converges using branch and bound. What am I doing wrong? I believe the problem to be in my fromto-loop. I use structures the calculate my total cost, while the example uses matrices... I tried using a three-dimensional array []([]([](...))), but that gave "instantiation fault in arg" errors when using Costarray[My1, My2, My3]. Thanks in advance! - S. vanden BrouckeReceived on Fri Oct 09 2009 - 15:59:10 CEST

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