Results 1 to 5 of 5

Thread: combination generator

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2006
    Posts
    109

    combination generator

    hey
    im making a decision table, and i have 8/9 rules with each answer being y or n. This is going to mean there are over 250 combernations!
    I was wondering if there is a program that works this out for you?
    Cheers
    Laura

  2. #2
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: combination generator

    Welcome to VBForums

    There are some algorithms that can do that, but what do you mean with decision table? Like an array? Can you clarify your idea a bit?

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 2006
    Posts
    109

    Re: combination generator

    hey
    sorry for not making myself clear, kind of hard to explain.
    I have to make a decision table and it looks like this
    hopefull this will help

    RULE | DOCTOR
    ---------------------------------------------------
    Name|y|n|n|n|
    Addy|Y|y|n|n|
    Date|y|y|y|n|
    Time|y|y|y|y|
    Book?|y|n|n|n|


    to explain this table:
    I have the rules that have to be yes in order for the booking to go a head.
    If they are all Y then the booking is a y

    If even one of them is a n then the booking is a n



    I have about 8 or 9 rules before the booking, which means i have over 200 different combernations (sp?) to work out

    Does this make sense?

  4. #4
    Member
    Join Date
    Nov 2006
    Posts
    43

    Re: combination generator

    Hi Laura.

    One way to do this would be to scan the array of answers and add 1 to a counter for all "Y" you encounter.
    If the final result is less than 8 or 9 then it would be a no.

    Example:
    VB Code:
    1. dim Answers(9) as string
    2. dim Counter as integer,a as integer
    3.  
    4. for a=1 to 9
    5. if ucase(Answers(a))="Y" then Counter=counter+1
    6. next
    7.  
    8. if counter<9 then Msgbox "No booking!"

    I don't know what your code looks like, if you even use an array so this will probably not fit into your code without modifications...

  5. #5
    Frenzied Member
    Join Date
    Oct 2003
    Posts
    1,301

    Re: combination generator

    You don't need to evaluate every possible combination.
    You need to evaluate each rule one by one and if one of the rules is false you make the decision false.
    VB Code:
    1. decision = (rule1 And rule2 And rule3 And rule4)
    Or
    VB Code:
    1. decision = True
    2. decision = decision And rule1
    3. decision = decision And rule2
    4. decision = decision And rule3
    5. decision = decision And rule4
    decision and the rules are booleans.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width