Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiomrebelo committed Jul 26, 2023
1 parent c91fdf4 commit dd46232
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
17 changes: 4 additions & 13 deletions src/client/controllers/Population.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class Population {
this.pause = false;
this.#data = data;
this.targetSemanticLayout = this.#calculateSemanticTargetLayout(this.#data);
console.log(`targetSemanticLayout`, this.targetSemanticLayout);
// console.log(`targetSemanticLayout`, this.targetSemanticLayout);

this.#typefaces = [];
this.updated = true;
Expand Down Expand Up @@ -56,13 +56,13 @@ export class Population {
this.updated = true;
}

// evolve
evolve = async () => {
const offspring = [];

// clean graphics hidden on canvas
await this.#cleanGraphics();
document.getElementById(`generation-number`).textContent=this.generations;

const offspring = [];

// copy the elite to next generation
const eliteSize = parseInt(this.params["evo"]["eliteSize"]);
Expand All @@ -76,15 +76,6 @@ export class Population {
// select the indices using Stochastic Ranking
const rank = await this.#stochasticRanking(fitness, constraints);


// sort population
// const newPopulation = [];
// for (let i=0; i<indices.length; i++) {
// newPopulation.push(this.population[indices[i]].copy());
// }
// this.population = newPopulation;


// crossover
for (let i = eliteSize; i < this.params["evo"]["popSize"]; i++) {
if (Math.random() <= this.params["evo"]["crossoverProb"]) {
Expand Down Expand Up @@ -353,7 +344,7 @@ export class Population {
this.population = this.population.sort((a,b) => (b.fitness-b.constraint) - (a.fitness-a.constraint));
// debug
// best individual fitness
console.log ("best individual=", this.population[0].fitness, this.population[0].constraint);
// console.log ("best individual=", this.population[0].fitness, this.population[0].constraint);
}

copy = (obj) => {
Expand Down
1 change: 0 additions & 1 deletion src/client/controllers/Poster.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ class Poster {
}

evaluate = async (dist) => {
// TODO: DIVIDE into parts
this.phenotype = await this.draw();
const noCurrentTypefaces = this.params["typography"]["typefaces"].length;

Expand Down

0 comments on commit dd46232

Please sign in to comment.