[eclipse-clp-users] Query

From: nishant raj <nishantraj5132_at_...6...>
Date: Thu, 2 Jun 2011 11:52:47 +0530
I have installed Eclipse 6.0 from http://eclipseclp.org/ and now i have a
doubt

For the Eclipse code which i have found on net and written below.. I have
compiled it and that part is ok.
now,
1. What will be its Querry. What to write in Querry. I wrote solve(0,6). but
then instead of executing or saying no if its wrong argument...the program
is hanging.
2. Here suppose I want that instead of 6 slots there should be user defined
slot and ser defined data for them....so how should i change its codes...and
please reply soon.

solve(Cost, Slots) :-
	data(Pref, Cap, Size),
	model(Pref, Cap, Size, Slots, Obj),
	optimize(min(Obj), Cost),
	( foreacharg(Slot,Slots) do writeln(Slot) ).


model(Pref, Cap, Size, Slots, Obj) :-
	dim(Cap, [NSlots]),
	dim(Size, [NGroups]),

	dim(Slots, [NSlots,NGroups]),
	Slots[1..NSlots,1..NGroups] $:: 0.0..1.0,
	integers(Slots[1..NSlots,1..NGroups]),

	( for(T,1,NSlots), param(Slots,Cap,Size,NGroups) do
	    ( for(G,1,NGroups), foreach(U,Used), param(Slots,Size,T) do
		U = Size[G] * Slots[T,G]
	    ),
	    sum(Used) $=< Cap[T]
	),

	( for(G,1,NGroups), param(Slots,NSlots) do
	    sum(Slots[1..NSlots,G]) $= 1
	),

	( multifor([T,G],1,[NSlots,NGroups]), foreach(C,Cs), param(Pref,Slots) do
	    C = Pref[T,G] * Slots[T,G]
	),
	Obj = sum(Cs).


data(Prefs, Capac, Compon) :-
	Prefs = [](
		 [](1, 2, 6, 5, 6, 6, 3, 4, 4, 1, 2, 4, 4, 3, 1, 5, 1, 4, 5, 6, 5,
2, 5, 5, 3, 2),
		 [](2, 3, 3, 2, 1, 4, 4, 2, 2, 6, 3, 1, 5, 5, 5, 6, 4, 2, 6, 4, 4,
5, 6, 2, 2, 1),
		 [](5, 1, 1, 6, 3, 5, 5, 3, 6, 5, 5, 3, 6, 2, 4, 1, 6, 3, 2, 5, 1,
1, 2, 6, 4, 3),
		 [](3, 6, 5, 3, 5, 3, 2, 1, 3, 3, 4, 2, 1, 1, 6, 2, 3, 5, 1, 3, 6,
3, 4, 3, 6, 5),
		 [](4, 4, 4, 4, 2, 2, 1, 6, 1, 4, 6, 5, 2, 4, 2, 3, 5, 6, 4, 2, 3,
6, 1, 1, 1, 6),
		 [](6, 5, 2, 1, 4, 1, 6, 5, 5, 2, 1, 6, 3, 6, 3, 4, 2, 1, 3, 1, 2,
4, 3, 4, 5, 4)
		),
	Capac = [](18, 18, 18, 18, 18, 18),
	Compon = [](5, 4, 4, 4, 3, 3, 3, 3, 3, 4, 4, 5, 5, 2, 5, 3, 4, 4, 3,
3, 3, 5, 2, 4, 4, 5).


-- 
NISHANT RAJ
3rd YEAR UNDERGRADUATE STUDENT
DEPARTMENT OF INDUSTRIAL ENGG.& MANAGEMENT
IIT KHARAGPUR
Phone (+91)-7501320429
Received on Thu Jun 02 2011 - 06:22:54 CEST

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