-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
code: separate genetic code to a new file
- Loading branch information
Showing
7 changed files
with
360 additions
and
316 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#ifndef __IFS_GENETICS_HPP_INCLUDED__ | ||
#define __IFS_GENETICS_HPP_INCLUDED__ | ||
|
||
class Transform; | ||
class PixelMap; | ||
class Ruleset; | ||
|
||
Transform merge_transforms(const Transform &t1, const Transform &t2, double p); | ||
void normalize_pixmap( PixelMap &p ); | ||
|
||
Ruleset * make_orphan(); | ||
Ruleset * mutate( const Ruleset &r ); | ||
Ruleset * crossover( const Ruleset &r1, const Ruleset &r2); | ||
|
||
|
||
struct GenePoolRecordT{ | ||
Ruleset *genome; | ||
double fitness; | ||
std::string origin; | ||
size_t generation; | ||
GenePoolRecordT():genome(NULL), fitness(-1){}; | ||
GenePoolRecordT(Ruleset *g): genome(g), fitness(-1){}; | ||
GenePoolRecordT(Ruleset *g, const std::string &o): genome(g), fitness(-1), origin(o){}; | ||
}; | ||
|
||
typedef std::vector<GenePoolRecordT> GenePoolT; | ||
|
||
GenePoolRecordT genetical_optimize( size_t pool_size, | ||
size_t orphans_per_generation, | ||
size_t n_mutants, | ||
size_t n_crossovers, | ||
PixelMap &sample, | ||
size_t generations, | ||
size_t stop_if_no_improvement_after); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.