-2

I have a following problem - I have a rule engine (drools) that evaluates risk score of transactions.If risk is too high (>200) then it is marked as unsafe. Each rule has their weight (1-100) that is assigned to risk score if rule gets executed.

I wanted to have a tool for optimizing the weights. And so I thought of genetic algorithm.

1. I would send batch of test transactions (with additional parameter that tells how they should be marked -> as unsafe or not) to engine to let it evaluate them

2. I would check how many rules were fired (it would determine number of chromosomes in genotype) and let's say if 5 was fired then...

3....I would create first population consisting of 500 genotypes, each having 5 chromosomes (and chromosome having gene with value ranging 1-100)

4. I would repeat step one for all genotypes in population

5. I would check what percent of transactions was marked correctly by using additional parameter I mentioned earlier.

6. I would assign to each genotype fitness function based on percentage of how many transactions were evaluated correctly

7. Repeating the cycle for number of generations until solution is reached (100% transactions are marked correctly) with crossovers, mutations etc.

It is my first time trying to do anything with genetic algorithms, so first thing I would like to clarify is

  • my understanding of how genotype/chromosome/gene works. In different sites they sometimes use the terms as substitutes of one another and it can be confsuing. I was learning terminology basing on jenetics library cause I was thinking to use it for implementation.

  • I later realized that I did not take into account one thing - I may evolve values of weights of rules but the weight is not the only thing important - it is also important to which rule the weight will be assigned! but I have no idea where I should put that additional information as to which rule the weight refers to.. somewehre in chromosome? That is the biggest issue for me, I just cannot see where to fit it in equation.

Joe C
  • 15,324
  • 8
  • 38
  • 50
anne
  • 13
  • 1
  • This is a site about programming. Your question appears to be about biology. We therefore cannot help you here. – Joe C Feb 09 '18 at 23:01
  • 1
    Since when genetic algorithms are not part of programming? – anne Feb 09 '18 at 23:02
  • Since when is "how does a chromosome work?" a part of programming? – Joe C Feb 09 '18 at 23:04
  • 3
    Since when did this have a question? – Zachary Feb 09 '18 at 23:04
  • Since I wrote that there are many definitions of chromosomes and I stated that I was taking my definition from 'jenetics' library... I simply asked if my way of thinking (i listed each step in implementing solution) has a chance to work. And i do not want to be rude but by saying it is a biology question you make an impression of not reading my description at all – anne Feb 09 '18 at 23:06
  • 3
    @JoeC: `chromosome` is used here in the sense of a genetic algorithm: an object that is mutated, crossed with another, etc., to create the next generation of model. – Prune Feb 09 '18 at 23:18

1 Answers1

1

Optimization is a fast and rapidly expanding field. You wil find that there are many terms flying around for the same characteristics, which can become very confusing. To me it seems you have a decent grasp of how the genetic algorithm works and it's associated terms (based on your outline in the question). For a nice reference please see this website. As a suggestion you can check out the MOEA Framework instead of jenetics. I think it's a better suited library for many optimisation techniques.

With regards to the second part of the question. If my understanding is correct you are uncertain how to keep track of which chromosome applies to which rule. If that is the case, you can simply keep your rules in a list and match them with the chromosomes. In other words the first chromosome of the individual (or genotype as per your reference) corresponds to the first rule in the problem. By doing so your can be sure to know which weight (chromosome value) applies to which rule.

Please correct me if I misunderstood.

TM00
  • 1,330
  • 1
  • 14
  • 26
  • You understood well, so I can just make list of rules and assume that for first element in list a corresponding value would be a first chromosome in genotype? I was thinking about it but I was wondering that it would mean i can match them randomly also and effect would be the same. That is why I am not so sure about all this, cause for example I could get solution 56 and 89 and say rule "Amount very high" is 89 while rule "high risk country" is 59. But the truth is that if I would assign opposite way it would still be ok? – anne Feb 10 '18 at 00:03
  • Well you don't have to assume it. When you evaluate each individual, you use the first chromosome to determine the value of the first rule in the list of rules (and so on for the 2nd, 3rd etc.). This will ensure that the chromosomes and rules correspond as long as the list of rules remain unchanged. By doing this you know which rule applies to which chromosome. You can match them in any order you like, as long as you know which goes where. In your example, its the GA's job to arrive at a solution which is assigned to be "ok", while the "bad" solutions will be filtered out during the iteration. – TM00 Feb 10 '18 at 06:39