Hi to all bin_packing(Bins, Weights, Capacity) :- dim(Bins,[N]), dim(Weights,[N]), writeln(N), writeln(Bin), (for(B,1,N), param(Weights,Bins,N,Capacity) do (for(J,1,N), fromto(0,In,Out,Sum), param(Weights,Bins,B) do Bins[J] #= B -> Out #= In + Weights[J] ; Out = In ), Sum #=< Capacity ). go :- % we let something be unknown problem(2,Bins, Weights,_Capacity), % N = 3, % if Bins is free we must set the length of it dim(Bins,[N]), Bins :: 1..N, dim(Weights, [N]), Weights :: 1..4, % Capacity = 5, Capacity :: 1..20, % bin_packing3(Bins,Weights,Capacity), bin_packing(Bins,Weights,Capacity), term_variables([Capacity,Weights,Bins],Vars), % search(Vars,0,first_fail,indomain,complete,[backtrack(Backtrack)]), minimize(search(Vars,0,first_fail,indomain,complete, [backtrack(Backtrack)]), Capacity), writeln(capacity:Capacity), writeln(bins:Bins), writeln(weights:Weights), writeln(backtracks:Backtrack), fail. problem(1, [](3,1,3), [](4,3,1), 5). % another example problem(2, [](3,1,3,2,2,1,2,3), [](4,3,1,3,4,3,1,2), 5). this is the bin packing problem ,I have a question about bin_packing part , about Bin[j]#=B this is for what and also I have such part like this in my code dim(T,[NCourse,NRoom,TS]), T[1..NCourse,1..NRoom,1..TS]:: 0..1, MT is T[1..NCourse,1..NRoom,1..TS], flatten(MT,Vars), length(Vars,NVars), %make_display_matrix(MT, roster), Vars :: 0..1, S is 0, ( for(I,1,NCourse), param(T,TS,CP,NRoom)do ( multifor([J,K],[1,1],[TS,NRoom]), fromto(0,In,Out,Sum), param(T,I)do writeln(I), writeln(J), writeln(K), M is T[I,J,K], writeln(M), *and in this part I think it has problem is it true or not* *Out=In+T[I,J,K],* writeln(Out) ), writeln("SUM"), X is CP[I], writeln(X), It stops at this point sum(Sum)#=CP[I], writeln(Sum) ) please guide me regardsReceived on Mon Jul 26 2010 - 06:31:29 CEST
This archive was generated by hypermail 2.3.0 : Wed Sep 25 2024 - 15:13:20 CEST