Click here to Skip to main content
15,888,733 members
Home / Discussions / Algorithms
   

Algorithms

 
AnswerRe: Classification with Self organizing map/Kohonen network [modified] PinPopular
BillWoodruff18-Aug-11 14:05
professionalBillWoodruff18-Aug-11 14:05 
GeneralRe: Classification with Self organizing map/Kohonen network Pin
Peter_in_278018-Aug-11 14:18
professionalPeter_in_278018-Aug-11 14:18 
GeneralRe: Classification with Self organizing map/Kohonen network Pin
BobJanova18-Aug-11 23:19
BobJanova18-Aug-11 23:19 
GeneralRe: Classification with Self organizing map/Kohonen network Pin
SharpSim21-Aug-11 22:17
SharpSim21-Aug-11 22:17 
AnswerRe: Classification with Self organizing map/Kohonen network Pin
BobJanova18-Aug-11 23:22
BobJanova18-Aug-11 23:22 
AnswerRe: Classification with Self organizing map/Kohonen network Pin
DaveAuld19-Aug-11 8:04
professionalDaveAuld19-Aug-11 8:04 
GeneralRe: Classification with Self organizing map/Kohonen network Pin
SharpSim22-Aug-11 22:33
SharpSim22-Aug-11 22:33 
Questionoptimizing the set of possible boolean outcomes of evaluating multiple conditions ? [modified] Pin
BillWoodruff16-Aug-11 19:02
professionalBillWoodruff16-Aug-11 19:02 
Hi,

Interesting the way that one intellectual quest can lead to another: my connecting-nodes-in-hierachies quest led to thinking about property change notifications in WinForms, which took a detour into WPF where so much work has been done with INotifyPropertyChanged automation, which led to experimenting with auto-code generation with T4 and PostSharp.

Which led to: I wrote a (non-recursive) code-generator ... which I will write-up for CP as a Tip or something if there's any interest ... that will generate a complete C# class for evaluating all possible logical comparisons of #n boolean variables. Here's the 'guts' of what it produces if I call it with an integer argument of #3:
if (Is_A && Is_B && Is_C)
{
    // test case: 0 : All Values True
    Console.WriteLine("Test0 passed");
    return;
}
else if (!Is_A && Is_B && Is_C)
{
    // test case: 1
    Console.WriteLine("Test1 passed");
    return;
}
else if (Is_A && !Is_B && Is_C)
{
    // test case: 2
    Console.WriteLine("Test2 passed");
    return;
}
else if (!Is_A && !Is_B && Is_C)
{
    // test case: 3
    Console.WriteLine("Test3 passed");
    return;
}
else if (Is_A && Is_B && !Is_C)
{
    // test case: 4
    Console.WriteLine("Test4 passed");
    return;
}
else if (!Is_A && Is_B && !Is_C)
{
    // test case: 5
    Console.WriteLine("Test5 passed");
    return;
}
else if (Is_A && !Is_B && !Is_C)
{
    // test case: 6
    Console.WriteLine("Test6 passed");
    return;
}
else if (!Is_A && !Is_B && !Is_C)
{
    // test case: 7
    Console.WriteLine("Test7 passed");
    return;
}
It has been many, many years since I once studied 'truth-tables' and 'decision-tables, etc. And, given a language ... C# ... that optimizes boolean expressions so that in "A && B && C" if 'A is not true, there is no evaluation of 'B and 'C ...

Assuming that any variable in the set of variables is as likely to be true or false in any given use case, it, of course, would not make any difference in what order you wrote out the tests. But, what interests me is how, when you have a sense of the probability distribution of evaluations, you might optimize.

So if you think that a test of 'A' is modal in your use-case, you move the evaluation of 'A to the front of the test; if you think evaluation of 'A is an edge-case infrequently evaluated, you write it last.

Where I am 'blocked' is in coming up with an algorithm to make a pass over the complete matrix of possibilities and optimize the tests based on some user supplied 'weighting.'

Perhaps the user of the code-generator should supply a string like "C,B,A" as its input parameter, and then interpret that as the order to write out the terms ?

Appreciate your opinions, and advice.

best, Bill

p.s. While the current code-generator is not Linquified, I'll probably end up going there. And I am also considering it might be better to generate a switch statement of the form:
switch (theSelector)
{
    case "TTT:
        break;  
    case "TFT:
        break;
    ... more cases ...
 
    case default;
        break; 
}

"In the River of Delights, Panic has not failed me." Jorge Luis Borges
modified on Wednesday, August 17, 2011 1:49 AM

GeneralRe: pruning the set of possible boolean outcomes of multiple variables ? Pin
David198716-Aug-11 20:00
David198716-Aug-11 20:00 
GeneralRe: pruning the set of possible boolean outcomes of multiple variables ? Pin
BillWoodruff17-Aug-11 14:50
professionalBillWoodruff17-Aug-11 14:50 
GeneralRe: pruning the set of possible boolean outcomes of multiple variables ? Pin
BillWoodruff17-Aug-11 21:46
professionalBillWoodruff17-Aug-11 21:46 
GeneralRe: pruning the set of possible boolean outcomes of multiple variables ? Pin
David198717-Aug-11 21:52
David198717-Aug-11 21:52 
GeneralRe: pruning the set of possible boolean outcomes of multiple variables ? Pin
BillWoodruff17-Aug-11 22:10
professionalBillWoodruff17-Aug-11 22:10 
GeneralRe: pruning the set of possible boolean outcomes of multiple variables ? Pin
David198717-Aug-11 22:19
David198717-Aug-11 22:19 
GeneralRe: pruning the set of possible boolean outcomes of multiple variables ? [modified] Pin
BillWoodruff24-Aug-11 20:55
professionalBillWoodruff24-Aug-11 20:55 
AnswerRe: optimizing the set of possible boolean outcomes of evaluating multiple conditions ? Pin
Luc Pattyn17-Aug-11 15:59
sitebuilderLuc Pattyn17-Aug-11 15:59 
GeneralRe: optimizing the set of possible boolean outcomes of evaluating multiple conditions ? Pin
BillWoodruff17-Aug-11 19:20
professionalBillWoodruff17-Aug-11 19:20 
Answerlink to usable c# sample of output of logic-matrix auto-generator for your review and comments Pin
BillWoodruff18-Aug-11 15:27
professionalBillWoodruff18-Aug-11 15:27 
AnswerRe: optimizing the set of possible boolean outcomes of evaluating multiple conditions ? [modified] Pin
RobCroll19-Aug-11 5:02
RobCroll19-Aug-11 5:02 
GeneralRe: optimizing the set of possible boolean outcomes of evaluating multiple conditions ? Pin
David198719-Aug-11 5:32
David198719-Aug-11 5:32 
GeneralRe: optimizing the set of possible boolean outcomes of evaluating multiple conditions ? Pin
RobCroll19-Aug-11 5:46
RobCroll19-Aug-11 5:46 
GeneralRe: optimizing the set of possible boolean outcomes of evaluating multiple conditions ? Pin
David198719-Aug-11 6:04
David198719-Aug-11 6:04 
GeneralRe: optimizing the set of possible boolean outcomes of evaluating multiple conditions ? [modified] Pin
BillWoodruff19-Aug-11 6:51
professionalBillWoodruff19-Aug-11 6:51 
AnswerRe: optimizing the set of possible boolean outcomes of evaluating multiple conditions ? Pin
GParkings3-Sep-11 5:57
GParkings3-Sep-11 5:57 
Questionconnection routing algorithm for connecting rectangles with lines ? Pin
BillWoodruff2-Aug-11 23:47
professionalBillWoodruff2-Aug-11 23:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.