Presentation is loading. Please wait.

Presentation is loading. Please wait.

G53CLP Constraint Logic Programming Constraint Optimisation Problems – Demos in OPL Studio Dr Rong Qu.

Similar presentations


Presentation on theme: "G53CLP Constraint Logic Programming Constraint Optimisation Problems – Demos in OPL Studio Dr Rong Qu."— Presentation transcript:

1 G53CLP Constraint Logic Programming Constraint Optimisation Problems – Demos in OPL Studio Dr Rong Qu

2 2 SEND MORE MONEY - model S E N D + M O R E = M O N E Y Variables: Domain: G53CLP – Constraint Logic ProgrammingDr R. Qu

3 3 SEND MORE MONEY - model //.mod file //declaration //variables enum Letters {S, E, N, D, M, O, R, Y}; //domain var int l[Letters] in 0..9; … G53CLP – Constraint Logic ProgrammingDr R. Qu

4 4 SEND MORE MONEY - model //.mod file //declaration … //problem - constraints solve { alldifferent(l) onDomain; l[S] <> 0; l[M] <> 0;... }; G53CLP – Constraint Logic ProgrammingDr R. Qu

5 5 SEND MORE MONEY - model //.mod file //declaration … //problem - constraints solve {... 1000*l[S] + 100*l[E] + 10*l[N] + l[D] + 1000*l[M] + 100*l[O] + 10*l[R] + l[E] = 10000*l[M] + 1000*l[O] + 100*l[N] + 10*l[E] + l[Y]; }; G53CLP – Constraint Logic ProgrammingDr R. Qu

6 G52AIP – AI Programming 6 SEND MORE MONEY - model

7 G52AIP – AI Programming 7 SEND MORE MONEY – decision tree

8 8 SEND MOST MONEY – model S E N D + M O S T = M O N E Y Variables: Domain: G53CLP – Constraint Logic ProgrammingDr R. Qu

9 9 Smuggler’s Knapsack Problem A smuggler has a knapsack of capacity 9 He can only make one trip He can smuggle Bottles of whiskysize 4profit 15 Bottles of perfumesize 3profit 10 Cartons of cigarettessize 2profit 7 He wants At least a profit of 30 Maximise the profit G53CLP – Constraint Logic ProgrammingDr R. Qu

10 10 Smuggler’s Knapsack Problem Variables W, P, C Domain {0, …, 9} Constraints 4*W + 3*P + 2*C <= 9; 15*W + 10*P + 7*C >=30; Bottles of whisky size 4 profit 15 Bottles of perfume size 3 profit 10 Cartons of cigarettes size 2 profit 7 G53CLP – Constraint Logic ProgrammingDr R. Qu

11 11 Knapsack Problems Which items should be put in the bag to maximise the profit G53CLP – Constraint Logic ProgrammingDr R. Qu

12 12 Knapsack Problems General problems Given a number of items with associated costs and values Determine the collection of items so that Total cost is minimised, or within a limit Total value is maximised G53CLP – Constraint Logic ProgrammingDr R. Qu

13 13 Simple Assignment Problem In a factory 4 workers 4 products Profits of assigning workers to products Each worker has one product Each product is assigned to one worker At least total profit >= 19 p1p2p3p4 w17134 w28251 w34372 w43163 G53CLP – Constraint Logic ProgrammingDr R. Qu

14 14 Simple Assignment Problem Variables l i,j : worker i assigned to product j Domain 0, 1 Constraints sum (l i ) = 1, i={..4} sum (weight i,j * l i,j ) >= 19 G53CLP – Constraint Logic ProgrammingDr R. Qu


Download ppt "G53CLP Constraint Logic Programming Constraint Optimisation Problems – Demos in OPL Studio Dr Rong Qu."

Similar presentations


Ads by Google