# How do I use decision tables to prioritize between objects - or should I do something different? [closed]

I have a case similar to this one: Multivariable decisions

The difference is, that it's not a single decision I need to make but more like I have a pool of (let's say 10 object) where each object has 4 attributes with 3-4 different states for each. I now need to select the ONE single most relevant of the objects based on comparing these attributes for each object.

What techniques can I use to implement this behaviour?

An example could be: you are in a theme park and you need to choose what roller coaster to try for a last ride before going home. There are 10 roller coasters in the park. Variables going into consideration are:

• How far away is the roller coster (can you reach it before the park closes)
• How wild is it (the wilder the better)
• Have you tried it before (you wanna try something new)
• How long time does the ride last (you don't wanner get locked up inside the park - or maybe you do actually :-)
• As I understand, you want to sort objects by their "fitness". Possibly you're looking for an algorithm similar to weighted product model. Your fitness/weight function can be of any form, I think your question is pretty vague on this part: "4 attributes with 3-4 different states for each". If you can tell which attributes are more important and which values are "better" for each attribute, than there's no "algorithm" to it, just a bunch of `if-else` clauses. Oct 8, 2015 at 18:03
• The example in the question can be a simple set of subroutines applies to a list of rides. Rides in a park fit into memory easily so computing distance to each, convert to time, add the ride runtime, remove rides done before then pick max wild who's end time will be before the park closes. Complex problems have too many options to fit into memory or check each one of (eg traveling salesman problem) So is your problem really as simple as this and if so why do anything complex write the most obvious code that could work. Oct 8, 2015 at 19:19

I will assume you are looking for a programming pattern to implement such decision making, not a concrete algorithm implementation.

So, I guess you need to assign weights to your objects based on attribute testing. For this you could have an abstract `AbstractWeightCalculator` class which has an abstract `calculateWeight(MyObject obj)` method.

Now you create various attribute testers:

• `DistanceWeightCalculator`: How far away is the roller coster
• `WildnessWeightCalculator`: How wild is it
• etc.

Now, you grab all your weight testers, apply them one by one to each object and get a sum of all weights of the objects. And then just sort the list you got by the weight.