Hello, I would like to use the the bb_min /3 predicate to find the lowest “Cost” solution available in my search / 6 results: The search is: search(XYs, 0, first_fail, indomain_split, complete, []), XYs is a list of points (X,Y) elements and the cost is equals to the maximum X value on the entire list, so my goal is to minimize this cost. I would like to know if I could use maxlist /2 to define the cost value or if there is any built-in predicate I could use, since it is not a simple scalar numeric list (only X value is considered). If not, my question would be how to define the Cost variable. Iterating over the list and find the maximum value sees not correct, since the search still did not happened yet. Here is the way I´m defining the predicate. In fact the code hangs when the bb_min is used. solve(Points, Polygons, NFs, Width, Length) :- ( foreach((X,Y),Points), param(Width, Length), fromto(XYs,[X,Y|XYs1],XYs1,[]) do X :: 0..Length, Y :: 0..Width, true ), %Define sheet boundaries constraints sheetBounds(Points, Polygons, Width, Length), %Define non overlap constraints ( foreach(Point1,Points) * foreach(Point2,Points), fromto(NFs,NFs1,NFs2,[]) do ( Point1 \== Point2 -> NFs1 = [NF|NFs2], outside_polygon1(Point1, Point2, NF) ; NFs1 = NFs2 ) ), %Cost calculation ( foreach((X,_),Points), fromto(Xs,[X|Xs1],Xs1,[]) do true ), maxlist(Xs, Cost), bb_min(search(XYs, 0, first_fail, indomain_split, complete, []), Cost, _), writeln(Points). I have a feeling that something is wrong on the Cost calculation, but I could not identify. I appreciate any help, Regards, Igor Kondrasovas Project Management Inovativa Tecnologia www.otimizecortes.com +55 47 3027-6442 +55 47 8839-1592Received on Wed May 19 2010 - 03:50:33 CEST
This archive was generated by hypermail 2.2.0 : Thu Feb 02 2012 - 02:31:58 CET