Travel Bike¶
The Travel Bike is a product configuration problem written in the COOM[X] language fragment. In addition to the City Bike, it contains numeric features and constraints involving arithmetics and aggregate functions.
fclingo
Problems involving large numeric ranges may time out
when using the clingo encoding due to large groundings.
Here, hybrid solver fclingo, which handles integers natively,
can be used by specifying the --solver fclingo
option.
Acknowledgements
The Travel Bike example has been provided by denkbares.
Usage¶
COOM model¶
product {
num .#/g 1-10000 totalWeight
num .#/kg 0-10 maxWeight
num .#/l 0-200 totalVolume
num .#/l 0-200 requestedVolume
Wheel frontWheel
Wheel rearWheel
Carrier carrier
Frame frame
Color color
}
structure Carrier {
0..3 Bag bag
}
structure Frame {
0..2 Bag bag
}
structure Bag {
Capacity capacity
Material material
}
enumeration Capacity {
attribute num/l volume
attribute num/gr weight
B10 = ( 10, 100)
B20 = ( 20, 250)
B50 = ( 50, 600)
B100 = (100, 1200)
}
enumeration Material {
Cotton
Leather
Polyester
}
enumeration Wheel {
attribute num/inch size
attribute num/gr weight
W20 = ( 20 650 )
W22 = ( 22 700 )
W24 = ( 24 800 )
W26 = ( 26 900 )
W28 = ( 28 1000 )
}
enumeration Color {
Red
Green
Yellow
Blue
}
behavior {
explanation "The bike can have a maximum of 4 bags."
require count(carrier.bag) + count(frame.bag) <= 4
explanation "The total weight is equal to the weight of the front wheel plus the weight of the rear wheel plus the sum of the weights of all bags on the carrier and the frame."
require totalWeight = frontWheel.weight + rearWheel.weight
+ sum(carrier.bag.capacity.weight)
+ sum(frame.bag.capacity.weight)
explanation "The total weight must not exceed the maximum weight."
require totalWeight <= maxWeight * 1000
explanation "The total volume is equal to the sum of the volumes of all bags on the carrier and the frame."
require totalVolume = sum(carrier.bag.capacity.volume) + sum(frame.bag.capacity.volume)
explanation "The total volume must be greater than or equal to the requested volume."
require totalVolume >= requestedVolume
explanation "If the color is red, then the size of the front wheel must be 20."
condition color = Red
require frontWheel.size = 20
}
behavior Bag {
explanation "If the material of the bag is leather, then the capacity must be B10."
condition material = Leather
require capacity = B10
}
Example solution¶
carrier[0]
carrier[0].bag[0]
carrier[0].bag[1]
carrier[0].bag[2]
frame[0]
frame[0].bag[0]
requestedVolume[0] = 200
totalVolume[0] = 200
totalWeight[0] = 3750
maxWeight[0] = 8
color[0] = "Red"
frontWheel[0] = "W20"
frontWheel[0].size[0] = 20
frontWheel[0].weight[0] = 650
rearWheel[0] = "W22"
rearWheel[0].size[0] = 22
rearWheel[0].weight[0] = 700
carrier[0].bag[0].capacity[0] = "B50"
carrier[0].bag[0].capacity[0].volume[0] = 50
carrier[0].bag[0].capacity[0].weight[0] = 600
carrier[0].bag[0].material[0] = "Polyester"
carrier[0].bag[1].capacity[0] = "B50"
carrier[0].bag[1].capacity[0].volume[0] = 50
carrier[0].bag[1].capacity[0].weight[0] = 600
carrier[0].bag[1].material[0] = "Polyester"
carrier[0].bag[2].capacity[0] = "B50"
carrier[0].bag[2].capacity[0].volume[0] = 50
carrier[0].bag[2].capacity[0].weight[0] = 600
carrier[0].bag[2].material[0] = "Cotton"
frame[0].bag[0].capacity[0] = "B50"
frame[0].bag[0].capacity[0].volume[0] = 50
frame[0].bag[0].capacity[0].weight[0] = 600
frame[0].bag[0].material[0] = "Polyester"