Live data from Hacker News

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

programmers.stackexchange.com

51–60 of 86 posts

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

#51
post #23

Earlier quoted context omitted.

Can you explain you think Genetic Programming is unsuitable? I honestly can't see why you think it wouldn't work.

Obviously various optimization techniques can be used essentially as poor-man's machine learners. That doesn't mean they're particularly good at it. In this case, Genetic Programming uses trees as its representation, and so it could be used as a tree-based classifier, but the OP has already indicated that he expects enormous numbers of rules, necessitating huge trees. For Genetic Programming, this translates into a g…

I do not think that he knew thousands of if-then rules would be needed, likely his estimate.

But that aside I believe that such a search space could be handled by GP. That very problem is what I've been tackling for sometime now. Its position on my list reflects that particular bias. But there are techniques. I use EDA's like MOSES and was heavily inspired by http://www-ia.hiof.no/~rolando/ but have my own original contributions. The method is also interactive for tough problems, these really help in reducing the search space. Although I have not succeeded in a use yet, I have been thinking hard about how category theory could be used to constrain space or perform particular automatic transofrmations (https://www.cs.ox.ac.uk/jeremy.gibbons/publications/origami...., https://www.cs.ox.ac.uk/people/jeremy.gibbons/publications/a...).

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

#52
post #26

Is it just me? It's not a good question, it shows lack of core coding experience. For example a video game consists of millions of possibilities/results in movement based on environment - it's not approached as a collection of thousands of if/then/else statements. In fact the movement of cows seems very much like video game coding, it needs a "cow engine".

I think it's a good question if only for the quality of answer it gained for the rest of us. But it's certainly not what I would expect from a very experienced developer.

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

#53
post #41

Earlier quoted context omitted.

I think it was a really good question. It showed that he had the intuitive instinct that there had to be a better way. He just didn't know how to ask for a "cow engine" by name.

I am not so certain. Note their question is not if there is another way - they are asking how to manage all the statements they are planning to write. Imagine being given a problem such as "add any two given integers but do not use math operators". A person without anything but if/then/else knowledge would proceed to try to write if (a==1 && b==2) c==3 and repeat it for every variation until they gave up. Someone wit…

Certain business logic can not be generalized as neatly as arithmetic. I work in health care. It is a real problem.

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

#54
post #26

Is it just me? It's not a good question, it shows lack of core coding experience. For example a video game consists of millions of possibilities/results in movement based on environment - it's not approached as a collection of thousands of if/then/else statements. In fact the movement of cows seems very much like video game coding, it needs a "cow engine".

It's a great question. It expresses a problem from the worldview of a coder with a particular, very common skillset. Which is something that other coders with the same problem and the same skillset will find in their searches. As long as the answers are good, it's a perfect use of the system.

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

#55

Even with the clue that he wants to "predict how cows move around in any landscape", his description seems like it wouldn't be enough any definite design advice. What do the states of the cows and the landscape look like? What is changed by the if-then-else results. Does he already have his rules? Is this for a biology project or a video game, etc. You could use a finite automaton system, an array of cow-states, a co…

Yes. The piece missing for me in most answers I've seen is eventing. Does one pump a series of events/state changes into the CowModel and see what actions pop-out? Does the model involve interactions with other cows where the actions of one cow cause actions of others? If so, one must have an event queue to handle chain reactions. How discrete are the events? Is there a "temp is 89F" event where, for every N minutes the cow is in that temperature in direct exposure, it becomes more likely to seek shade? If so, the "it is 89F" event must be triggered multiple times. And, such a rule requires that the past states of the cow be retained. I think the if/then/else logic is only part of the solution to a simulation problem of this sort.

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

#56
post #41

Earlier quoted context omitted.

I think it was a really good question. It showed that he had the intuitive instinct that there had to be a better way. He just didn't know how to ask for a "cow engine" by name.

I am not so certain. Note their question is not if there is another way - they are asking how to manage all the statements they are planning to write. Imagine being given a problem such as "add any two given integers but do not use math operators". A person without anything but if/then/else knowledge would proceed to try to write if (a==1 && b==2) c==3 and repeat it for every variation until they gave up. Someone wit…

i don't see why people downvoted you.

I write AI perception systems for "realtime simulations", and you are exactly correct.

while on the surface it may seem like "if/else" will give you the solution you need, the sheer number of permutations will make it infeasable.

That said, there are "known solutions" and some novel solutions to this problem too. Perhaps if/else is really what this person needs, but there are other potentially better solutions documented.

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

#57
post #26

Is it just me? It's not a good question, it shows lack of core coding experience. For example a video game consists of millions of possibilities/results in movement based on environment - it's not approached as a collection of thousands of if/then/else statements. In fact the movement of cows seems very much like video game coding, it needs a "cow engine".

How do video games solve it?

Do you have any material one can read to learn more about this?

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

#58
post #57
post #26

Is it just me? It's not a good question, it shows lack of core coding experience. For example a video game consists of millions of possibilities/results in movement based on environment - it's not approached as a collection of thousands of if/then/else statements. In fact the movement of cows seems very much like video game coding, it needs a "cow engine".

How do video games solve it? Do you have any material one can read to learn more about this?

Often through physics engines. You express a bunch of constraints then let a physics engine solve them on each time step (and sometimes across multiple time steps).

Custom (non-physics) solutions involve declarative sets of constraints being solved by some sort of engine; such solutions often start to resemble physics engines even if the physical rules even if the constraints are not exactly physical.

Learning how to use a physics engine, first, then how those physics engines work, is a good start to understanding these kinds of problems.

Edit: I'm really surprised the stackexchange answers don't mention this.

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

#59
post #57
post #26

Is it just me? It's not a good question, it shows lack of core coding experience. For example a video game consists of millions of possibilities/results in movement based on environment - it's not approached as a collection of thousands of if/then/else statements. In fact the movement of cows seems very much like video game coding, it needs a "cow engine".

How do video games solve it? Do you have any material one can read to learn more about this?

[deleted]
Post reply on HN