Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive
 
genetics-computer.png

SIA Coin is the cryptocurrency that allows you to do some earnings by renting your spare hard disk space. In order to be able to rent your space, you must configure some parameters (some of them technical, some others economical). These parameters help the SIA environment to assign a score; the way the score is assigned is complex. I have spent some code reading and I have found the following:

  1. Select the node that is in the n = total_active_hosts * 3 / 5 place. Instead of using the median that uses the element in the middle (1 / 2), SIA uses the 3 / 5.
  2. a correction factor is calculated using the estimated score of the host selected from the first step. c = 1 / estimated_score. The estimated score is given by the SIA API.
  3. All other active hosts' estimated score is multiplied by the correction factor in order to get a score.

Please note that I am not a golang coder. I may have some misreadings. What it is not really clear to me is how the estimated score is calculated (es(X) = n). SIA Coin documentation says it is a combination of prices, uptime, free space, and other things. But they haven't documented (yet) exactly the math behind that number. Again, I am not a golang coder.

When a renter looks for space, the renter will select those hosts with the highest score. So the big question, what parameters can I adjust in order to have a higher score and start doing some profits?

Well, thank god the genetic algorithms exist.

Some Thoughts about Genetic Algorithms

The logic behind them is not complex or sophisticated, indeed the search process is more kind of brute force. Yes, I will need big CPU if I am going to make this very often.

Genetic algorithms borrow the following concepts from biology:

  • Population and generations
  • Selection of the fittest
  • Reproduction
  • Mutation

The Population in the SIA Coin Environment

A population is created by setting a set of individuals. Each individual is considered to have a unique chromosome. Like the real world, the chromosome is a complex set of variables (genes). In the Genetic Algorithms, a chromosome is represented by a set of genes. Each variable is considered to be a gene.

In the SIA Coin environment, the chromosome is formed from the following settings (genes):

  1. acceptingcontracts
  2. maxdownloadbatchsize - maxduration
  3. maxrevisebatchsize
  4. windowsize
  5. collateral
  6. collateralbudget - maxcollateral
  7. mincontractprice
  8. mindownloadbandwidthprice
  9. minstorageprice
  10. minuploadbandwidthprice

So, when creating the population a call to the SIA coin API such as hostdb/active to get a list of the current active host and then a hostdb/host to get the detail.

Selection of the Fittest in the SIA Coin Environment

Fitness is determined by how close each chromosome comes to providing a solution to the equation. Fitness evaluation will return a rank. Then, you can discard those who don't meet the criteria.

I will use the host/estimatescore API call to get the conversion rate.

Reproduction in the SIA Coin Environment

Two chromosomes (the parents) mix to produce a child. The key here is knowing how many genes each parent will contribute. This is totally random. Like nature, sometimes a child seems to be the younger version of one of the parents (all but one gene are copied from one parent), other times the child looks alike of both parents (each parent has contributed the 50% of the genes).

Some algorithms replace the new child with the lesser fit parent.

Mutation in the SIA Coin Environment

Randomly change one or more values of the genes. Mutation is important; because of the randomness of the genetic algorithm, sometimes the searching may fall into a loop, this mechanism helps to break it.

Mutation rate should be low.

The Proposed Genetic Algorithm to Improve Host Score

siacoin genetic optimization algorithmThe following actions are:

  1. Natural Selection: Using the SIA Coin API, we will retrieve the currently active server. Select the 10% top servers and build its chromosome of each one.
  2. Selection of the fittest: Evaluate each chromosome and sort them by the given value and discard the last 25%. Keep those slots open.
  3. Reproduction: per each free slot, take the top pair and reproduce a new chromosome. For example, if you have two free slots, take chromosome 1 & 2 for first free slot and chromosome 3 & 4 for the second free slot.
    Each chromosome of the new child should be from one of the parents. The selection of whose chromosome is will be totally random.
  4. Mutation: Each value of each chromosome will have a 1/100 chance to mutate. Mutation value (increment or decrement) will be totally random.
  5. Iteration: This process should be done more than once. Not sure how many generations.
  6. Selection of the fittest and return of the fittest one: As the second step, the chromosomes will be sorted and the top one will be returned as the best answer.
blog comments powered by Disqus

About

Read about IT, Migration, Business, Money, Marketing and other subjects.

Some subjects: FusionPBX, FreeSWITCH, Linux, Security, Canada, Cryptocurrency, Trading.