GithubHelp home page GithubHelp logo

Comments (5)

guliashvili avatar guliashvili commented on July 18, 2024

Hi,
Can you share FloatGenotypeFactory code?

from watchmaker.

DcortezMeleth avatar DcortezMeleth commented on July 18, 2024

Sure. It's just class wrapping list of Doubles. AbstractGenotype contains nothing at all.

    public class FloatGenotype extends AbstractGenotype {

        private List<Double> genes;

        public FloatGenotype(final List<Double> genes) {
            super();
            this.genes = genes;
        }

        public FloatGenotype(final FloatGenotype genotype) {
            super();
            this.genes = genotype.getGenes();
        }

        public List<Double> getGenes() {
            return genes;
        }

        public void setGenes(final List<Double> genes) {
            this.genes = genes;
        }

        @Override
        public String toString() {
            String result = "[";
            for(Double f : getGenes()) {
                result += f + " ";
            }
            return result + "] ";
        }
    }

from watchmaker.

guliashvili avatar guliashvili commented on July 18, 2024

Hi,
It's FloatGenotype I was interested in FloatGenotypeFactory

from watchmaker.

DcortezMeleth avatar DcortezMeleth commented on July 18, 2024

My mistake.

public class FloatGenotypeFactory extends AbstractGenotypeFactory<FloatGenotype> {

    private static final Double UPPERBOUND = 1.0d;

    private static final Double LOWERBOUND = 0.0d;

    private static final Integer DIM = 3;

    private Integer dim;

    public FloatGenotypeFactory() {
        super(LOWERBOUND, UPPERBOUND);
        this.dim = DIM;
    }

    public FloatGenotypeFactory(final Double lowerbound, final Double upperbound, final Integer dim) {
        super(lowerbound, upperbound);
        this.dim = dim;
    }

    @Override
    public FloatGenotype generateRandomCandidate(final Random rng) {
        List<Double> genes = new ArrayList<>();
        for(int i=0; i<dim; i++) {
            genes.add(uniform(rng));
        }
        return new FloatGenotype(genes);
    }
}

public abstract class AbstractGenotypeFactory<T extends AbstractGenotype> extends AbstractCandidateFactory<T> {

    private Double lowerbound;

    private Double upperbound;

    public AbstractGenotypeFactory(final Double lowerbound, final Double upperbound) {
        this.lowerbound = lowerbound;
        this.upperbound = upperbound;
    }

    protected Double uniform(final Random rng) {
        return rng.nextDouble() * (this.upperbound - this.lowerbound) + this.lowerbound ;
    }
}

from watchmaker.

guliashvili avatar guliashvili commented on July 18, 2024

Hi,
I had similar problem but not same. In my case sometimes population size was less then elite count (even in configuration was not). I resolved it in my forked version, seems like it was top of iceberg, and framework for some reasons can keep population on fixed size. If you can provide me with your whole source code, I'll try to resolve the problem in my fork(as this repo is not changed for years)

from watchmaker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.