Live data from Hacker News

How can one manage thousands of IF…THEN…ELSE rules?

programmers.stackexchange.com

1–10 of 86 posts

Re: How can one manage thousands of IF…THEN…ELSE rules?

#4
Such a great question. Want to predict cow movement while taking into consideration sudden events, food and sun, using thousands of if then rules? Sounds like the perfect problem for one of the following tree learners that not only manage themselves but build the model for you, in order of suitability to the problem* :

Genetic Programming

ADTree

Random Forest

Decision Tree

Most of the work would be in figuring out the best way to gather all the data.

*opinion.

Re: How can one manage thousands of IF…THEN…ELSE rules?

#6
You really don't want to think of this in terms of IF ... THEN ... ELSE but as individual binary or multi-path choices. These are most efficiently handled with hash tables that choose a route through a logic diagram in a way that is more intuitive than If ... THEN ... ELSE as well as more efficient.

You start by writing a logic flowchart that you understand, then you reduce the logic flowchart to code, usually automatically. This is how a logic flowchart looks:

http://en.wikipedia.org/wiki/File:LampFlowchart.svg

Here is the article it appears in:

http://en.wikipedia.org/wiki/Flowchart

The single most important parts of this process are:

1. That you understand the logic diagram and see that it meets the program's requirements.

2. That there is a way to turn the logic flowchart into code, ideally without human intervention.

3. That the rebuild time be short between adding a new logical step and testing the resulting program.

Re: How can one manage thousands of IF…THEN…ELSE rules?

#7
post #6

You really don't want to think of this in terms of IF ... THEN ... ELSE but as individual binary or multi-path choices. These are most efficiently handled with hash tables that choose a route through a logic diagram in a way that is more intuitive than If ... THEN ... ELSE as well as more efficient. You start by writing a logic flowchart that you understand, then you reduce the logic flowchart to code, usually automa…

Maybe I'm off the mark, but whenever I see a long runon procedure full of if-then-else, I think "This is a job for a state machine!" With that approach, you can exhaustively provide actions for every combination of states and events. You can also immediately identify the code responsible for handling any state+event. You can also track which state+event transitions have been tested automatically.

Re: How can one manage thousands of IF…THEN…ELSE rules?

#8
post #4

Such a great question. Want to predict cow movement while taking into consideration sudden events, food and sun, using thousands of if then rules? Sounds like the perfect problem for one of the following tree learners that not only manage themselves but build the model for you, in order of suitability to the problem* : Genetic Programming ADTree Random Forest Decision Tree Most of the work would be in figuring out th…

I also thought GP and decision trees. Trying to hard code all the logic of a living being by hand is programmatic masturbation and also not the best way to model an artificial intelligence.

Re: How can one manage thousands of IF…THEN…ELSE rules?

#9
post #3

If only these questions appeared on one's résumé...

What, are you insinuating that asking about great big if-then-else trees means you'd never hire that person? Because, what, you've never been a complete novice programmer before?

Considering the question-asker has a specific problem to solve, I would even hazard they probably aren't a programmer by trade.

Re: How can one manage thousands of IF…THEN…ELSE rules?

#10
post #3

If only these questions appeared on one's résumé...

What, are you insinuating that asking about great big if-then-else trees means you'd never hire that person? Because, what, you've never been a complete novice programmer before? Considering the question-asker has a specific problem to solve, I would even hazard they probably aren't a programmer by trade.

I'd say the fact that person is asking this question is a very good sign - they have a gut feeling that something's off with IF-THEN spaghetti.
Post reply on HN