/
index.php
72 lines (48 loc) · 2.37 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
/**
* Created by PhpStorm.
* User: User
* Date: 24-Dec-15
* Time: 23:04
*/
session_start();
include_once "includes/masterpage/header.php"; ?>
<h1>Give an Aesthetic Rating to each title</h1>
<form action="test.php" method="post" id="form1">
<input type="submit" value="Submit">
</form>
<?php
$element = new Element("h1", 1);
$element->addProperty(new Property(1, "color", ["#1abc9c", "#16a085", "#f1c40f", "#f39c12", "#40d47e", "#27ae60", "#e67e22", "#d35400", "#3498db", "#2980b9", "#e74c3c", "#c0392b", "#9b59b6", "#8e44ad", "#ecf0f1", "#bdc3c7", "#34495e", "#2c3e50", "#95a5a6","#7f8c8d"]));
$element->addProperty(new Property(2, "text-align", ["center", "left", "right", "justified"]));
$element->addProperty(new Property(3, "text-decoration", ["overline", "underline", "line-through"]));
$element->addProperty(new Property(4, "font-family", ["Tangerine", "Inconsolata", "Droid Sans"]));
$element->addProperty(new Property(5, "font-style", ["normal", "italic", "oblique"]));
$element->addProperty(new Property(6, "font-weight", ["normal", "lighter", "bold"]));
$element->addProperty(new Property(7, "letter-spacing", ["-3px", "-2px", "-1px", "0px", "1px", "2px", "3px"]));
$element->addProperty(new Property(7, "background-color", ["#1abc9c", "#16a085", "#f1c40f", "#f39c12", "#40d47e", "#27ae60", "#e67e22", "#d35400", "#3498db", "#2980b9", "#e74c3c", "#c0392b", "#9b59b6", "#8e44ad", "#ecf0f1", "#bdc3c7", "#34495e", "#2c3e50", "#95a5a6","#7f8c8d"]));
$ga = new GeneticAlgorithm(5, 0.9,0.1,1);
$population = $ga->initPopulation($element);
$individuals = $population->getIndividuals();
//Printing Style
echo "<style>";
foreach ($individuals as $id => $individual) {
echo "\n".$ga->decode($id+1, $individual, $element);
}
echo "</style>";
//Printing headers
foreach ($individuals as $id => $individual) {
$id++;
echo "Encoded: ".$individual."<br>";
echo "Decoded: <h1 id='individual{$id}'>This is a Title</h1>";
echo '<input type="text" class="input_range" id="range_'.$id.'" form="form1" name="individual_'.$id.'" value="" />';
}
//TEMP:: Setting random fitness
foreach ($population->getIndividuals() as &$i) {
$i->setFitness(Random::generate());
}
$ga->evalPopulation($population);
echo $population->getPopulationFitness()."<br>";
$_SESSION['population'] = serialize($population);
?>
<?php include_once "includes/masterpage/footer.php "; ?>