Skip to content

Commit

Permalink
feat: layoutSemantics metric #54
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiomrebelo committed Jul 25, 2023
1 parent c3ff4c0 commit 02942f5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
3 changes: 2 additions & 1 deletion cypress/e2e/evolution.cy.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import 'cypress-wait-until';

const TESTING_EXAMPLES = [
{text: `Never Mind¶The Bollocks,¶Here's the¶Sex Pistols`}
{text: `Never Mind¶The Bollocks,¶Here's the¶Sex Pistols`},
{text: `The children¶almost broken¶by the world¶become the adults¶most likely¶to change it`}
]

// check if system is evolving
Expand Down
2 changes: 1 addition & 1 deletion src/client/Params.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class Params {
static imageMaxSize = 1024;

static evolution = {
popSize: 20,
popSize: 50,
noGen: 400,
crossoverProb: 0.75,
mutationProb: 0.30,
Expand Down
11 changes: 5 additions & 6 deletions src/client/controllers/Population.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export class Population {
this.pause = false;
this.#data = data;
this.targetSemanticLayout = this.#calculateSemanticTargetLayout(this.#data);
console.log(`targetSemanticLayout`, this.targetSemanticLayout);

this.#typefaces = [];
this.updated = true;
Expand Down Expand Up @@ -106,7 +107,6 @@ export class Population {
this.population = offspring;

// evaluate
console.log ("evolve-eval");
await this.evaluate();

// log config data to file
Expand Down Expand Up @@ -311,12 +311,8 @@ export class Population {

evaluate = async () => {
// force evaluation of individuals
let i=0;
for (let individual of this.population) {
console.group(i);
await individual.evaluate(this.targetSemanticLayout);
i++;
console.groupEnd();
}

// sort the population based on staticPenalty
Expand Down Expand Up @@ -356,6 +352,9 @@ export class Population {

#staticPenalty = async () => {
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);
}

copy = (obj) => {
Expand Down Expand Up @@ -476,7 +475,7 @@ export class Population {
}
}

#calculateSemanticTargetLayout = (data, emphasis= 0.5) => {
#calculateSemanticTargetLayout = (data, emphasis= 0.1) => {
// emphasis is the min importance in layout of neutrals (between 0.1 and 1)
// emotional score is added to the emphasis
let dist = [];
Expand Down
4 changes: 2 additions & 2 deletions src/public/app.js

Large diffs are not rendered by default.

0 comments on commit 02942f5

Please sign in to comment.