CSCI5240 - Combinatorial Search and Optimization with ...

28
CSCI5240 - Combinatorial Search and Optimization with Constraints Tutorial 1

Transcript of CSCI5240 - Combinatorial Search and Optimization with ...

CSCI5240 - Combinatorial Search and Optimization with Constraints

Tutorial 1

Teacher & Tutor

• Prof. Jimmy Lee ([email protected])

Room 1009

• Xuming HUANG ([email protected])

Room 1005

Accessing me

• Piazza

• Email

• Office

Today covers

• Review of Module 1

• Workshops & Asg 1

• Submission

Module 1• variables / parameters, array

• constraints, solve item, output item

• satisfaction / optimisation

• model / instance

• iteration

Army Recruitment

Recruit an army as strong as possible

Maximise

Army Recruitment

maximize 6F + 10L+ 8Z + 40Jsubject to13F + 21L+ 17Z + 100J ≤ budget

0 ≤ F ≤ 10000 ≤ L ≤ 4000 ≤ Z ≤ 5000 ≤ J ≤ 150

F,L, Z, J ∈ Z, budget = 10000

1

F L Z J

Army Recruitment

maximize 6F + 10L+ 8Z + 40Jsubject to13F + 21L+ 17Z + 100J ≤ budget

0 ≤ F ≤ 10000 ≤ L ≤ 4000 ≤ Z ≤ 5000 ≤ J ≤ 150

F,L, Z, J ∈ Z, budget = 10000

1

F L Z J Decisions to make

Army Recruitment

variable

parameter

constraint

solve itemoutput item

A MiniZinc Model

• variable must have a var prefix

• order doesn’t matter

• solve item is a must (satisfy, maximize, minimize), while output item is optional

Data File

an unassignedparameter

provide a data file

input a valueor

Data Filean unassigned

parameter

provide a data file

input a valueor

In army.dzn

From Variables to Array

array[1..4] of var int: army

F L Z J

range type name

army[1] army[2] army[3] army[4]

From Variables to ArrayF <= 1000

L <= 400

Z <= 500

J <= 150

army[1] army[2] army[3] army[4]

1000 400 500 150

army[1] <= 1000

army[2] <= 400

army[3] <= 500army[4] <= 150

<= <= <= <=

array[1..4] of int: capacity

From Variables to ArrayF <= 1000

L <= 400

Z <= 500

J <= 150

army[1] army[2] army[3] army[4]

1000 400 500 150

army[1] <= capacity[1]

army[2] <= capacity[2]

army[3] <= capacity[3]army[4] <= capacity[4]

<= <= <= <=

array[1..4] of int: capacity

From Variables to ArrayF <= 1000

L <= 400

Z <= 500

J <= 150

army[1] army[2] army[3] army[4]

1000 400 500 150

<= <= <= <=

array[1..4] of int: capacity

From 1 to 4:

army[i] <= capacity[i]

forall

constraint forall (i in 1..4) (army[i] <= capacity[i]);

constraint forall (i in 1..4) (army[i] >= 0);

In army.dznIn army.mzn

sum

army[1] army[2] army[3] army[4]

13 21 17 100

array[1..4] of var int: army

6 10 8 40

array[1..4] of int: price

array[1..4] of int: strength

Model / Instance

army.mzn: model

army.dzn: data

instance = model + data

Today covers

• Review of Module 1

• Workshops & Asg 1

• Submission

Workshops

• Workshop 0 and Workshop 1

• try solving them before watching the solution video

Assignment 1

• cryptarithm problem (of different types)

puzzle one solution

Today covers

• Review of Module 1

• Workshops & Asg 1

• Submission

Submissionunzip, find the file submit.py

Submissionrun submit.py and select which part(s) to submit

Submissioninput your account and submission token

(generated from the webpage)

Submissioninput your account and submission token

(generated from the webpage)

SubmissionSubmission completed and

check result from the webpage