[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

boolean decisions

Robin Becker

2/5/2008 10:52:00 AM

I have a couple of business decisions to make that essentially use 6 binary
input variables. After the business users have gone back and forth for two weeks
trying to build special case rules I asked them to make up a table containing
all of the input possibilities and specify what should happen in each case.
There are only 64 rows and some of the decisions are obviously explainable in
simple ways ie

if a and not b do action 1

is there a way to derive simplified rules for each binary outcome? I'm sure this
is a standard sort of problem and probably some python code is out there. It
seems to me I need to solve an overdetermined binary equation system and then
choose the solution with the shortest number of terms or something, but perhaps
I am daft.
--
Robin Becker

10 Answers

Diez B. Roggisch

2/5/2008 11:26:00 AM

0

Robin Becker wrote:

> I have a couple of business decisions to make that essentially use 6
> binary input variables. After the business users have gone back and forth
> for two weeks trying to build special case rules I asked them to make up a
> table containing all of the input possibilities and specify what should
> happen in each case. There are only 64 rows and some of the decisions are
> obviously explainable in simple ways ie
>
> if a and not b do action 1
>
> is there a way to derive simplified rules for each binary outcome? I'm
> sure this is a standard sort of problem and probably some python code is
> out there. It seems to me I need to solve an overdetermined binary
> equation system and then choose the solution with the shortest number of
> terms or something, but perhaps I am daft.

Triggered this in some deep-rootet parts of my brain stem:

http://en.wikipedia.org/wiki/Quine-McCluskey...

Diez

Paul Hankin

2/5/2008 11:56:00 AM

0

On Feb 5, 10:52 am, Robin Becker <ro...@reportlab.com> wrote:
> I have a couple of business decisions to make that essentially use 6 binary
> input variables. After the business users have gone back and forth for two weeks
> trying to build special case rules I asked them to make up a table containing
> all of the input possibilities and specify what should happen in each case.
> There are only 64 rows and some of the decisions are obviously explainable in
> simple ways ie
>
> if a and not b do action 1
>
> is there a way to derive simplified rules for each binary outcome? I'm sure this
> is a standard sort of problem and probably some python code is out there. It
> seems to me I need to solve an overdetermined binary equation system and then
> choose the solution with the shortest number of terms or something, but perhaps
> I am daft.

Why bother? Build a hash table mapping the 64 cases to a function or
method-name. That way you can keep the business rules intact in your
code, it'll be just as fast (or faster), and your code will be much
easier to fix when one of the lines of that table changes (not that
business logic EVER changes ;). I'd be tempted to include the business
rule table as a text file or string, and parse it at program startup
to build the hashtable. That way anyone can look at or modify the
table, even if they know nothing about python or coding.

--
Paul Hankin

Zentrader

2/5/2008 12:07:00 PM

0

>and then choose the solution with the
>shortest number of terms or something

Experience says that one should not assume that there is a one to one
relationship, ("the" solution). Some event can trigger more than one
combination of the 6 binary input variables. And experience says that
the business users are not aware of all of the possible outcomes or
that there may be some one-to-many relationships, which may be why
they want the computer to do it. This is a problem that occurs
everywhere. There are various decision table techniques, but good
algorithms seem to be in short supply.

Robin Becker

2/5/2008 2:30:00 PM

0

Paul Hankin wrote:
> On Feb 5, 10:52 am, Robin Becker <ro...@reportlab.com> wrote:
>> I have a couple of business decisions to make that essentially use 6 binary
>> input variables. After the business users have gone back and forth for two weeks
>> trying to build special case rules I asked them to make up a table containing
>> all of the input possibilities and specify what should happen in each case.
>> There are only 64 rows and some of the decisions are obviously explainable in
>> simple ways ie
>>
>> if a and not b do action 1
>>
>> is there a way to derive simplified rules for each binary outcome? I'm sure this
>> is a standard sort of problem and probably some python code is out there. It
>> seems to me I need to solve an overdetermined binary equation system and then
>> choose the solution with the shortest number of terms or something, but perhaps
>> I am daft.
>
> Why bother? Build a hash table mapping the 64 cases to a function or
> method-name. That way you can keep the business rules intact in your
> code, it'll be just as fast (or faster), and your code will be much
> easier to fix when one of the lines of that table changes (not that
> business logic EVER changes ;). I'd be tempted to include the business
> rule table as a text file or string, and parse it at program startup
> to build the hashtable. That way anyone can look at or modify the
> table, even if they know nothing about python or coding.
.......

I think the problem is actually less simple than that. Although they can
enumerate many or all of the rows of the table I suspect that the business
people don't always know why they choose particular outcomes; often they're not
looking at most of the input choices at all they just concentrate on one or
other. If they could formulate the rules properly they would, but somehow they
can't.

If I can obtain some simplified rules for the two or three outputs and present
them to the business guys they may actually be able to confirm their own
original choices/and or reject/confirm the rule.
--
Robin Becker

Robin Becker

2/5/2008 2:31:00 PM

0

Diez B. Roggisch wrote:
> Robin Becker wrote:
>
>.......
>> terms or something, but perhaps I am daft.
>
> Triggered this in some deep-rootet parts of my brain stem:
>
> http://en.wikipedia.org/wiki/Quine-McCluskey...
......
seems like the sort of thing I can deal with though at least for this small case.
--
Robin Becker

Robin Becker

2/5/2008 2:34:00 PM

0

Zentrader wrote:
>> and then choose the solution with the
>> shortest number of terms or something
>
> Experience says that one should not assume that there is a one to one
> relationship, ("the" solution). Some event can trigger more than one
> combination of the 6 binary input variables. And experience says that
> the business users are not aware of all of the possible outcomes or
> that there may be some one-to-many relationships, which may be why
> they want the computer to do it. This is a problem that occurs
> everywhere. There are various decision table techniques, but good
> algorithms seem to be in short supply.
in practice the decisions are mostly singletons and I'm fairly sure which order
they have to be made in.
--
Robin Becker

Diez B. Roggisch

2/5/2008 3:12:00 PM

0

> I think the problem is actually less simple than that. Although they can
> enumerate many or all of the rows of the table I suspect that the business
> people don't always know why they choose particular outcomes; often
> they're not looking at most of the input choices at all they just
> concentrate on one or other. If they could formulate the rules properly
> they would, but somehow they can't.
>
> If I can obtain some simplified rules for the two or three outputs and
> present them to the business guys they may actually be able to confirm
> their own original choices/and or reject/confirm the rule.

Maybe creating descision trees from real-world data might also be a way to
infer the business-rules.

Diez

Paddy

2/5/2008 3:45:00 PM

0

On Feb 5, 10:52 am, Robin Becker <ro...@reportlab.com> wrote:
> I have a couple of business decisions to make that essentially use 6 binary
> input variables. After the business users have gone back and forth for two weeks
> trying to build special case rules I asked them to make up a table containing
> all of the input possibilities and specify what should happen in each case.
> There are only 64 rows and some of the decisions are obviously explainable in
> simple ways ie
>
> if a and not b do action 1
>
> is there a way to derive simplified rules for each binary outcome? I'm sure this
> is a standard sort of problem and probably some python code is out there. It
> seems to me I need to solve an overdetermined binary equation system and then
> choose the solution with the shortest number of terms or something, but perhaps
> I am daft.
> --
> Robin Becker

Try:
http://en.wikipedia.org/wiki/Ka...

Their are useful links at the bottom, too.

- Paddy.

news-noreply

2/6/2008 7:16:00 AM

0

Statestep (which includes Python code generation) might
be something to look at.
It's designed to help the user create simplified rules
to begin with rather than derive them post hoc (it's
really for much bigger problems where enumerating
individual rules like you've done would be impractical)
....
However, if you start with an "exploded" set of atomic
rules like you now have, you could create simplified
rules yourself, progressively deleting the rules you are
replacing (identified as overlaps by Statestep); this
way, at least the tool is checking the correctness of
the transformation from individual to simplified rules
(if you make a mistake then a conflict will be reported
rather than an overlap).

Michael

Robin Becker

2/6/2008 11:26:00 AM

0

news-noreply@statestep.com wrote:
> Statestep (which includes Python code generation) might
> be something to look at.
> It's designed to help the user create simplified rules
> to begin with rather than derive them post hoc (it's
> really for much bigger problems where enumerating
> individual rules like you've done would be impractical)
> ...
> However, if you start with an "exploded" set of atomic
> rules like you now have, you could create simplified
> rules yourself, progressively deleting the rules you are
> replacing (identified as overlaps by Statestep); this
> way, at least the tool is checking the correctness of
> the transformation from individual to simplified rules
> (if you make a mistake then a conflict will be reported
> rather than an overlap).
>
> Michael
All of this has been useful, but I over estimated the people I work with. having
reduced the problem to only 4 input variables. They carefully produced a
spreadsheet with 20 scenarios. There were clearly 4 scenarios missing, but also
4 pairs of duplicates in the input space; worse only one of the duplicate pairs
agreed on the action. sigh
-impossibly yrs-
Robin Becker