The first Git version
This commit is contained in:
20
Deaf2.0/Deaf2.0.sln
Normal file
20
Deaf2.0/Deaf2.0.sln
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2012
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Deaf2.0", "Deaf2.0\Deaf2.0.vcxproj", "{532A4CEC-F8E9-467D-A01E-2E4D814E0D3F}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Win32 = Debug|Win32
|
||||||
|
Release|Win32 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{532A4CEC-F8E9-467D-A01E-2E4D814E0D3F}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{532A4CEC-F8E9-467D-A01E-2E4D814E0D3F}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{532A4CEC-F8E9-467D-A01E-2E4D814E0D3F}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{532A4CEC-F8E9-467D-A01E-2E4D814E0D3F}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
63
Deaf2.0/Deaf2.0/Agent.cpp
Normal file
63
Deaf2.0/Deaf2.0/Agent.cpp
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
#include "Agent.h"
|
||||||
|
#include "Settings.h"
|
||||||
|
#include <random>
|
||||||
|
|
||||||
|
Agent::Agent(int fGene, int mGene, bool deaf, bool signL, float socialP){
|
||||||
|
this->mGenome.assign(1, mGene);
|
||||||
|
this->fGenome.assign(1, fGene);
|
||||||
|
|
||||||
|
this->isDeaf = deaf;
|
||||||
|
this->knowsSignLanguage = signL;
|
||||||
|
this->socialPosition = socialP;
|
||||||
|
// this->bachelority = bachelority;
|
||||||
|
this->fatherID = -1;
|
||||||
|
this->motherID = -1;
|
||||||
|
|
||||||
|
this->alreadyMarried = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Agent::Agent(Agent* father, int fID, Agent* mother, int mID){
|
||||||
|
this->fatherID = fID;
|
||||||
|
this->motherID = mID;
|
||||||
|
|
||||||
|
std::default_random_engine& generator = Settings::RANDOM_GENERATOR;
|
||||||
|
std::uniform_int_distribution<int> distribution(0,1); // ERROR - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||||
|
int mAllele = distribution(generator);
|
||||||
|
int fAllele = distribution(generator);
|
||||||
|
|
||||||
|
|
||||||
|
// <20><><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
this->mGenome = (mAllele == 0 ? mother->mGenome : mother->fGenome);
|
||||||
|
this->fGenome = (fAllele == 0 ? father->mGenome : father->fGenome);
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
this->isDeaf = (this->mGenome.at(0) + this->fGenome.at(0)) > 1 ? true : false;
|
||||||
|
|
||||||
|
|
||||||
|
if(!this->isDeaf)
|
||||||
|
{
|
||||||
|
std::uniform_real_distribution<float> distributionR(0.f,1.f);
|
||||||
|
float deafChance = distributionR(generator);
|
||||||
|
if(deafChance < Settings::SPONTANEOUS_DEAF)
|
||||||
|
this->isDeaf = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>.
|
||||||
|
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD> <20><><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><> <20><><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>
|
||||||
|
// (<28><><EFBFBD><EFBFBD> <20> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
||||||
|
// 2018.11.20 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
//this->knowsSignLanguage = (father->knowsSignLanguage && father->isDeaf
|
||||||
|
// || mother->knowsSignLanguage && mother->isDeaf);
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>)
|
||||||
|
// <20><><EFBFBD><EFBFBD>: <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
std::normal_distribution<float> distrN(0,0.1f);
|
||||||
|
float delta = distrN(generator);
|
||||||
|
this->socialPosition = 0.5f*(mother->socialPosition + father->socialPosition) + delta;
|
||||||
|
|
||||||
|
this->alreadyMarried = false;
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
// delta = distribution(generator);
|
||||||
|
// this->bachelority = 0.5f*(mother->bachelority + father->bachelority) + delta;
|
||||||
|
// this->age = 0;
|
||||||
|
}
|
||||||
36
Deaf2.0/Deaf2.0/Agent.h
Normal file
36
Deaf2.0/Deaf2.0/Agent.h
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
#pragma once
|
||||||
|
#include<vector>
|
||||||
|
|
||||||
|
class Agent{
|
||||||
|
|
||||||
|
protected:
|
||||||
|
std::vector<int> mGenome;
|
||||||
|
std::vector<int> fGenome;
|
||||||
|
|
||||||
|
bool isDeaf;
|
||||||
|
bool knowsSignLanguage;
|
||||||
|
float socialPosition;
|
||||||
|
// float bachelority;
|
||||||
|
|
||||||
|
int fatherID;
|
||||||
|
int motherID;
|
||||||
|
// int age;
|
||||||
|
// Agent* mate;
|
||||||
|
// Agent* father;
|
||||||
|
// Agent* mother;
|
||||||
|
// std::vector<Agent*> children;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Agent(int fGene, int mGene, bool deaf, bool signL,
|
||||||
|
float socialP); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
Agent(Agent*,int, Agent*, int);
|
||||||
|
bool deaf() const { return isDeaf;}
|
||||||
|
int getDeafAllelesCount() const { return mGenome.at(0)+fGenome.at(0);}
|
||||||
|
bool knowsSign() const { return knowsSignLanguage;}
|
||||||
|
int getFatherID() const { return fatherID;}
|
||||||
|
int getMotherID() const { return motherID;}
|
||||||
|
float getSocialP() const { return socialPosition;}
|
||||||
|
|
||||||
|
void teachSignLanguage() { this->knowsSignLanguage = true;}
|
||||||
|
bool alreadyMarried;
|
||||||
|
};
|
||||||
83
Deaf2.0/Deaf2.0/Deaf2.0.vcxproj
Normal file
83
Deaf2.0/Deaf2.0/Deaf2.0.vcxproj
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{532A4CEC-F8E9-467D-A01E-2E4D814E0D3F}</ProjectGuid>
|
||||||
|
<RootNamespace>Deaf20</RootNamespace>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup />
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<AdditionalIncludeDirectories>E:\Programming\boost_1_66_0;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<AdditionalIncludeDirectories>E:\Programming\boost_1_66_0;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<AdditionalLibraryDirectories>E:\Programming\boost_1_66_0\lib32-msvc-11.0;E:\Programming\boost_1_66_0\libs;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="Agent.cpp" />
|
||||||
|
<ClCompile Include="Main.cpp" />
|
||||||
|
<ClCompile Include="Processor.cpp" />
|
||||||
|
<ClCompile Include="Settings.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="Agent.h" />
|
||||||
|
<ClInclude Include="Processor.h" />
|
||||||
|
<ClInclude Include="Settings.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
||||||
15
Deaf2.0/Deaf2.0/Main.cpp
Normal file
15
Deaf2.0/Deaf2.0/Main.cpp
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#include "Processor.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
int main(int argc, char** argv){
|
||||||
|
|
||||||
|
std::string filename = "";
|
||||||
|
if(argc >= 2)
|
||||||
|
filename = argv[1];
|
||||||
|
|
||||||
|
Processor p;
|
||||||
|
|
||||||
|
p.run(filename);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
734
Deaf2.0/Deaf2.0/Processor.cpp
Normal file
734
Deaf2.0/Deaf2.0/Processor.cpp
Normal file
@@ -0,0 +1,734 @@
|
|||||||
|
#include "Agent.h"
|
||||||
|
#include "Processor.h"
|
||||||
|
#include "Settings.h"
|
||||||
|
#include <random>
|
||||||
|
#include <ctime>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
|
#include <boost/algorithm/string.hpp>
|
||||||
|
#include <boost/tokenizer.hpp>
|
||||||
|
#include <boost/math/distributions/beta.hpp>
|
||||||
|
#include <boost/random/random_device.hpp>
|
||||||
|
#include <boost/random/uniform_real_distribution.hpp>
|
||||||
|
|
||||||
|
#ifdef LINUX
|
||||||
|
#define sscanf_s scanf
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void Processor::run(std::string fileName){
|
||||||
|
if(fileName.size() > 1){
|
||||||
|
this->initSettings(fileName);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
//this->initSettings("D:/Projects/Deaf2.5/Deaf2.0/INIT.txt");
|
||||||
|
//Settings::OUTPUT_FILE = "D:/model/Deaf2.0 by Sergey 06.08/OUTPUT/output.deaf25.txt";
|
||||||
|
}
|
||||||
|
int initPopSizeM = Settings::INIT_POP_SIZE_M;
|
||||||
|
int initPopSizeW = Settings::INIT_POP_SIZE_W;
|
||||||
|
///float deafAlleleRatio = Settings::DEAF_ALLELE_RATIO;
|
||||||
|
|
||||||
|
float birthRateH = Settings::BIRTH_RATE_H; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
float birthRateD = Settings::BIRTH_RATE_D; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
int maxGenerations = Settings::MAX_GENERATIONS;
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
std::cout<<"Initializing output file..\t";
|
||||||
|
std::ofstream outputFile(Settings::OUTPUT_FILE);
|
||||||
|
outputFile<<"Generation\tTotalPopulation\tMen\tWomen\tDeaf";
|
||||||
|
outputFile<<"\tDD marriages\tDD children";
|
||||||
|
outputFile<<"\tDH marriages\tDH children";
|
||||||
|
outputFile<<"\tHH marriages\tHH children";
|
||||||
|
outputFile<<"\tDA frequency\tDA homozygotes frequency";
|
||||||
|
// TODO <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||||
|
outputFile<<std::endl;
|
||||||
|
std::cout<<"Done\n";
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
//std::vector<std::vector<float> > matrixCurrent;
|
||||||
|
//std::vector<std::vector<float> > matrixFuture;
|
||||||
|
|
||||||
|
std::vector<Agent*> men;
|
||||||
|
std::vector<Agent*> women;
|
||||||
|
std::vector<Agent*> newMen;
|
||||||
|
std::vector<Agent*> newWomen;
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20> <20><><EFBFBD>
|
||||||
|
std::vector<Agent*> deafMen;
|
||||||
|
std::vector<Agent*> deafWomen;
|
||||||
|
std::vector<Agent*> deafNewMen;
|
||||||
|
std::vector<Agent*> deafNewWomen;
|
||||||
|
|
||||||
|
|
||||||
|
std::default_random_engine& generator = Settings::RANDOM_GENERATOR;
|
||||||
|
//generator.seed(std::time(0));
|
||||||
|
//RandomDevice::RandomDevice(unsigned long n) : rand_seed(n), engine(n){ }
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
std::cout<<"Creating men..("<<initPopSizeM<<")\t";
|
||||||
|
int deafHomozygotes = (int) (initPopSizeM*Settings::DEAF_HOMOZYGOTES);
|
||||||
|
int hearHomozygotes = (int) (initPopSizeM*Settings::HEAR_HOMOZYGOTES);
|
||||||
|
int heterozygores = initPopSizeM - deafHomozygotes - hearHomozygotes;
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
||||||
|
for(int i = 0; i < hearHomozygotes; i++){
|
||||||
|
bool isDeaf = false;
|
||||||
|
int alleleFather = 0;
|
||||||
|
int alleleMother = 0;
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
std::uniform_real_distribution<float> distrUI(0.f,1.f);
|
||||||
|
if(distrUI(generator) < Settings::SPONTANEOUS_DEAF)
|
||||||
|
isDeaf = true;
|
||||||
|
|
||||||
|
float mean = isDeaf ? Settings::SOCIAL_MEAN_D : Settings::SOCIAL_MEAN_H;
|
||||||
|
float sigma= isDeaf ? Settings::SOCIAL_VAR_D : Settings::SOCIAL_VAR_H;
|
||||||
|
std::normal_distribution<float> distN(mean, sigma);
|
||||||
|
float socialP = distN(generator);
|
||||||
|
|
||||||
|
float signLangLevel = isDeaf ? Settings::SIGN_LANG_DEAF : Settings::SIGN_LANG_HEAR;
|
||||||
|
bool signL = distrUI(generator) < signLangLevel ? true: false;
|
||||||
|
|
||||||
|
Agent* a = new Agent(alleleFather, alleleMother, isDeaf, signL, socialP);
|
||||||
|
men.push_back(a);
|
||||||
|
|
||||||
|
if(isDeaf)
|
||||||
|
deafMen.push_back(a);
|
||||||
|
} // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
||||||
|
for(int i = 0; i < heterozygores; i++){
|
||||||
|
bool isDeaf = false;
|
||||||
|
int alleleFather = 1; // TODO: <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
int alleleMother = 0;
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
std::uniform_real_distribution<float> distrUI(0.f,1.f);
|
||||||
|
if(distrUI(generator) < Settings::SPONTANEOUS_DEAF)
|
||||||
|
isDeaf = true;
|
||||||
|
|
||||||
|
float mean = isDeaf ? Settings::SOCIAL_MEAN_D : Settings::SOCIAL_MEAN_H;
|
||||||
|
float sigma= isDeaf ? Settings::SOCIAL_VAR_D : Settings::SOCIAL_VAR_H;
|
||||||
|
std::normal_distribution<float> distN(mean, sigma);
|
||||||
|
float socialP = distN(generator);
|
||||||
|
|
||||||
|
float signLangLevel = isDeaf ? Settings::SIGN_LANG_DEAF : Settings::SIGN_LANG_HEAR;
|
||||||
|
bool signL = distrUI(generator) < signLangLevel ? true: false;
|
||||||
|
|
||||||
|
Agent* a = new Agent(alleleFather, alleleMother, isDeaf, signL, socialP);
|
||||||
|
men.push_back(a);
|
||||||
|
|
||||||
|
if(isDeaf)
|
||||||
|
deafMen.push_back(a);
|
||||||
|
} // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
for(int i = 0; i < deafHomozygotes; i++){
|
||||||
|
bool isDeaf = true;
|
||||||
|
int alleleFather = 1;
|
||||||
|
int alleleMother = 1;
|
||||||
|
|
||||||
|
float mean = isDeaf ? Settings::SOCIAL_MEAN_D : Settings::SOCIAL_MEAN_H;
|
||||||
|
float sigma= isDeaf ? Settings::SOCIAL_VAR_D : Settings::SOCIAL_VAR_H;
|
||||||
|
std::normal_distribution<float> distN(mean, sigma);
|
||||||
|
float socialP = distN(generator);
|
||||||
|
|
||||||
|
std::uniform_real_distribution<float> distrUI(0.f,1.f);
|
||||||
|
float signLangLevel = isDeaf ? Settings::SIGN_LANG_DEAF : Settings::SIGN_LANG_HEAR;
|
||||||
|
bool signL = distrUI(generator) < signLangLevel ? true: false;
|
||||||
|
|
||||||
|
Agent* a = new Agent(alleleFather, alleleMother, isDeaf, signL, socialP);
|
||||||
|
men.push_back(a);
|
||||||
|
|
||||||
|
if(isDeaf)
|
||||||
|
deafMen.push_back(a);
|
||||||
|
}// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
std::random_shuffle(men.begin(), men.end());
|
||||||
|
std::random_shuffle(deafMen.begin(), deafMen.end());
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
std::cout<<"Done\n";
|
||||||
|
|
||||||
|
std::cout<<"Creating women..\t";
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
deafHomozygotes = (int) (initPopSizeW*Settings::DEAF_HOMOZYGOTES);
|
||||||
|
hearHomozygotes = (int) (initPopSizeW*Settings::HEAR_HOMOZYGOTES);
|
||||||
|
heterozygores = initPopSizeW - deafHomozygotes - hearHomozygotes;
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
||||||
|
for(int i = 0; i < hearHomozygotes; i++){
|
||||||
|
bool isDeaf = false;
|
||||||
|
int alleleFather = 0;
|
||||||
|
int alleleMother = 0;
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
std::uniform_real_distribution<float> distrUI(0.f,1.f);
|
||||||
|
if(distrUI(generator) < Settings::SPONTANEOUS_DEAF)
|
||||||
|
isDeaf = true;
|
||||||
|
|
||||||
|
float mean = isDeaf ? Settings::SOCIAL_MEAN_D : Settings::SOCIAL_MEAN_H;
|
||||||
|
float sigma= isDeaf ? Settings::SOCIAL_VAR_D : Settings::SOCIAL_VAR_H;
|
||||||
|
std::normal_distribution<float> distN(mean, sigma);
|
||||||
|
float socialP = distN(generator);
|
||||||
|
|
||||||
|
float signLangLevel = isDeaf ? Settings::SIGN_LANG_DEAF : Settings::SIGN_LANG_HEAR;
|
||||||
|
bool signL = distrUI(generator) < signLangLevel ? true: false;
|
||||||
|
|
||||||
|
Agent* a = new Agent(alleleFather, alleleMother, isDeaf, signL, socialP);
|
||||||
|
women.push_back(a);
|
||||||
|
|
||||||
|
if(isDeaf)
|
||||||
|
deafWomen.push_back(a);
|
||||||
|
} // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
||||||
|
for(int i = 0; i < heterozygores; i++){
|
||||||
|
bool isDeaf = false;
|
||||||
|
int alleleFather = 1; // TODO: <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
int alleleMother = 0;
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
std::uniform_real_distribution<float> distrUI(0.f,1.f);
|
||||||
|
if(distrUI(generator) < Settings::SPONTANEOUS_DEAF)
|
||||||
|
isDeaf = true;
|
||||||
|
|
||||||
|
float mean = isDeaf ? Settings::SOCIAL_MEAN_D : Settings::SOCIAL_MEAN_H;
|
||||||
|
float sigma= isDeaf ? Settings::SOCIAL_VAR_D : Settings::SOCIAL_VAR_H;
|
||||||
|
std::normal_distribution<float> distN(mean, sigma);
|
||||||
|
float socialP = distN(generator);
|
||||||
|
|
||||||
|
float signLangLevel = isDeaf ? Settings::SIGN_LANG_DEAF : Settings::SIGN_LANG_HEAR;
|
||||||
|
bool signL = distrUI(generator) < signLangLevel ? true: false;
|
||||||
|
|
||||||
|
Agent* a = new Agent(alleleFather, alleleMother, isDeaf, signL, socialP);
|
||||||
|
women.push_back(a);
|
||||||
|
|
||||||
|
if(isDeaf)
|
||||||
|
deafWomen.push_back(a);
|
||||||
|
} // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
for(int i = 0; i < deafHomozygotes; i++){
|
||||||
|
bool isDeaf = true;
|
||||||
|
int alleleFather = 1;
|
||||||
|
int alleleMother = 1;
|
||||||
|
|
||||||
|
float mean = isDeaf ? Settings::SOCIAL_MEAN_D : Settings::SOCIAL_MEAN_H;
|
||||||
|
float sigma= isDeaf ? Settings::SOCIAL_VAR_D : Settings::SOCIAL_VAR_H;
|
||||||
|
std::normal_distribution<float> distN(mean, sigma);
|
||||||
|
float socialP = distN(generator);
|
||||||
|
|
||||||
|
std::uniform_real_distribution<float> distrUI(0.f,1.f);
|
||||||
|
float signLangLevel = isDeaf ? Settings::SIGN_LANG_DEAF : Settings::SIGN_LANG_HEAR;
|
||||||
|
bool signL = distrUI(generator) < signLangLevel ? true: false;
|
||||||
|
|
||||||
|
Agent* a = new Agent(alleleFather, alleleMother, isDeaf, signL, socialP);
|
||||||
|
women.push_back(a);
|
||||||
|
|
||||||
|
if(isDeaf)
|
||||||
|
deafWomen.push_back(a);
|
||||||
|
}// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
std::random_shuffle(women.begin(), women.end());
|
||||||
|
std::random_shuffle(deafWomen.begin(), deafWomen.end());
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
std::cout<<"Done\n";
|
||||||
|
|
||||||
|
std::cout<<"\nMain cycle\n";
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||||
|
for(int gen = 0; gen < maxGenerations; gen++){
|
||||||
|
std::cout<<"Generation\t"<<gen<<"\n";
|
||||||
|
int marriageDD = 0;
|
||||||
|
int marriageDH = 0;
|
||||||
|
int marriageHH = 0;
|
||||||
|
int childrenDD = 0;
|
||||||
|
int childrenDH = 0;
|
||||||
|
int childrenHH = 0;
|
||||||
|
|
||||||
|
//std::cout<<"\tInitializing matrixCurrent\t";
|
||||||
|
//std::vector<float> vect(women.size(),0.0f);
|
||||||
|
//matrixCurrent.assign(men.size(),vect);
|
||||||
|
//std::cout<<"\tDone\n";
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD> <<3C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>
|
||||||
|
std::cout<<"\tInitializing settledPairs\t";
|
||||||
|
std::uniform_real_distribution<float> distrUI(0.f,1.f);
|
||||||
|
std::cout<<".";
|
||||||
|
std::vector<std::vector<std::pair<unsigned int,float> > > settledPairs(men.size());
|
||||||
|
std::cout<<".";
|
||||||
|
for(int i = 0; i < settledPairs.size(); i++){
|
||||||
|
float f = distrUI(generator);
|
||||||
|
int sign = f < 0.5f ? -1 : 1;
|
||||||
|
int candidatePairs = Settings::CANDIDATE_PAIRS_MEAN
|
||||||
|
+ (int)(sign*f*Settings::CANDIDATE_PAIRS_VAR);
|
||||||
|
|
||||||
|
// TODO: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
int left = i - candidatePairs/2;
|
||||||
|
int right = i + candidatePairs/2;
|
||||||
|
|
||||||
|
// HACK: 2018/11/23 <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
if(men.at(i)->deaf() && Settings::DEAF_COMMUNITY_MODEL == 1){
|
||||||
|
left = 0;
|
||||||
|
right = women.size() - 1;
|
||||||
|
candidatePairs = women.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(left < 0){
|
||||||
|
right -= left;
|
||||||
|
left = 0;
|
||||||
|
}
|
||||||
|
if(right >= women.size()){
|
||||||
|
right = women.size() - 1;
|
||||||
|
left = right - candidatePairs;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::pair<unsigned int,float> > pairs(candidatePairs);
|
||||||
|
for(unsigned int p = 0; p < pairs.size(); p++){
|
||||||
|
pairs.at(p).first = left;
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>-<2D><><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
//matrixCurrent.at(i).at(left)
|
||||||
|
pairs.at(p).second = esteem(men.at(i),women.at(left));
|
||||||
|
left++;
|
||||||
|
}
|
||||||
|
settledPairs.at(i) = pairs;
|
||||||
|
}
|
||||||
|
// (END) <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
std::cout<<"Done\n";
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
// <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
/*for(unsigned int m = 0; m < men.size(); m++){
|
||||||
|
// <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
for(unsigned int w = 0; w < women.size(); w++){
|
||||||
|
if(matrixCurrent.at(m).at(w) >= 0.0f)
|
||||||
|
matrixCurrent.at(m).at(w) = esteem(men.at(m),women.at(w));
|
||||||
|
}
|
||||||
|
} */
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
/* std::cout<<"\tGenerating offsprings\t";
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
// <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
std::cout << "MENS" << std::endl;
|
||||||
|
for (auto m = 0; m < settledPairs.size(); ++m)
|
||||||
|
{
|
||||||
|
std::cout << "MEN: " << m << ": ";
|
||||||
|
for (auto w = 0; w < settledPairs[m].size(); ++w)
|
||||||
|
{
|
||||||
|
std::cout << settledPairs[m][w].first << " : " << settledPairs[m][w].second << "; ";
|
||||||
|
}
|
||||||
|
std::cout << std::endl;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
for(int m = 0; m < men.size(); m++){
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
int bestW = 0;
|
||||||
|
float bestScore = 0.0f;
|
||||||
|
|
||||||
|
/* <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
for(int w = 0; w < women.size(); w++){
|
||||||
|
if(matrixCurrent.at(m).at(w) > bestScore){
|
||||||
|
bestScore = matrixCurrent.at(m).at(w);
|
||||||
|
bestW = w;
|
||||||
|
}
|
||||||
|
} // <20><><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
**/
|
||||||
|
// <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
for(unsigned int p = 0; p < settledPairs.at(m).size(); p++){
|
||||||
|
unsigned int w = settledPairs.at(m).at(p).first;
|
||||||
|
|
||||||
|
if(women.at(w)->alreadyMarried)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if(settledPairs.at(m).at(p).second/*matrixCurrent.at(m).at(w)*/ > bestScore){
|
||||||
|
bestScore = settledPairs.at(m).at(p).second; //matrixCurrent.at(m).at(w);
|
||||||
|
bestW = w;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// (END) <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
if(bestScore <= 0.0f)
|
||||||
|
continue; // <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
int* mariage = &marriageHH;
|
||||||
|
int* childrenType = &childrenHH;
|
||||||
|
|
||||||
|
float meanChildren = birthRateH;
|
||||||
|
if((men.at(m)->deaf() && !women.at(bestW)->deaf()) ||
|
||||||
|
(!men.at(m)->deaf() && women.at(bestW)->deaf())){
|
||||||
|
mariage = &marriageDH;
|
||||||
|
childrenType = &childrenDH;
|
||||||
|
}
|
||||||
|
if(men.at(m)->deaf() && women.at(bestW)->deaf()){
|
||||||
|
mariage = &marriageDD;
|
||||||
|
childrenType = &childrenDD;
|
||||||
|
}
|
||||||
|
if(men.at(m)->deaf() || women.at(bestW)->deaf()){
|
||||||
|
meanChildren = birthRateD;
|
||||||
|
}
|
||||||
|
|
||||||
|
float correction = (Settings::BETA_A+Settings::BETA_B)/Settings::BETA_A*meanChildren;
|
||||||
|
float fChildren = 1.0f;
|
||||||
|
|
||||||
|
#ifndef LINUX
|
||||||
|
std::_Beta_distribution<float> distrB(Settings::BETA_A,Settings::BETA_B);
|
||||||
|
fChildren = distrB(generator)*correction; //
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef LINUX
|
||||||
|
boost::random::random_device rng;
|
||||||
|
boost::random::uniform_real_distribution<> uniform(0,1);
|
||||||
|
|
||||||
|
boost::math::beta_distribution<> distrB(Settings::BETA_A,Settings::BETA_B);
|
||||||
|
fChildren = quantile(distrB, uniform(rng)) * correction;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int children = (int) std::floor(fChildren+0.5f);
|
||||||
|
(*mariage)++;
|
||||||
|
(*childrenType) += children;
|
||||||
|
|
||||||
|
// TODO: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> + <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||||
|
std::vector<Agent*> newSibs; // <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
std::vector<Agent*> deafSibs;// <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
for(int i = 0; i < children; i++){
|
||||||
|
Agent* newAgent = new Agent(men.at(m), m, women.at(bestW), bestW);
|
||||||
|
newSibs.push_back(newAgent);
|
||||||
|
if(newAgent->deaf()){
|
||||||
|
deafSibs.push_back(newAgent);
|
||||||
|
}
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
std::uniform_int_distribution<int> distrUI(0,1);
|
||||||
|
if(distrUI(generator) == 0){
|
||||||
|
newMen.push_back(newAgent);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
newWomen.push_back(newAgent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1 - <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD>-<2D><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
if(men.at(m)->deaf() || women.at(bestW)->deaf()){
|
||||||
|
if(men.at(m)->knowsSign() || women.at(bestW)->knowsSign()){
|
||||||
|
for(auto i = 0; i < newSibs.size(); i++){
|
||||||
|
newSibs.at(i)->teachSignLanguage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2 - <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
else if(deafSibs.size() > 0){
|
||||||
|
std::uniform_real_distribution<float> distrUF(0.f,1.f);
|
||||||
|
// <20>) <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||||
|
bool sibsKnowSL = false;
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
for(auto i = 0; i < deafSibs.size(); i++){
|
||||||
|
if(distrUF(generator) <= Settings::SIGN_LANG_DEAF){
|
||||||
|
deafSibs.at(i)->teachSignLanguage();
|
||||||
|
sibsKnowSL = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
for(auto i = 0; i < newSibs.size(); i++){
|
||||||
|
if(!newSibs.at(i)->deaf() && distrUF(generator) <= Settings::SIGN_LANG_HEAR){
|
||||||
|
newSibs.at(i)->teachSignLanguage();
|
||||||
|
sibsKnowSL = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// <20>) <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
if(men.at(m)->knowsSign() || women.at(bestW)->knowsSign() || sibsKnowSL){
|
||||||
|
for(auto i = 0; i < newSibs.size(); i++){
|
||||||
|
newSibs.at(i)->teachSignLanguage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 3 - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
else {
|
||||||
|
std::uniform_real_distribution<float> distrUF(0.f,1.f);
|
||||||
|
for(auto i = 0; i < newSibs.size(); i++){
|
||||||
|
if(distrUF(generator) <= Settings::SIGN_LANG_HEAR){
|
||||||
|
newSibs.at(i)->teachSignLanguage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// (END) <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
women.at(bestW)->alreadyMarried = true;
|
||||||
|
//for(int i = m; i < men.size(); i++){
|
||||||
|
// matrixCurrent.at(i).at(bestW) = -100.0f;
|
||||||
|
//}
|
||||||
|
} // <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
std::cout<<"Done\n";
|
||||||
|
|
||||||
|
std::cout<<"\tSaving model state\t";
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
int totalP = men.size()+women.size();
|
||||||
|
outputFile<<gen;
|
||||||
|
outputFile<<"\t"<<totalP;
|
||||||
|
outputFile<<"\t"<<men.size();
|
||||||
|
outputFile<<"\t"<<women.size();
|
||||||
|
|
||||||
|
int totalDeaf = 0;
|
||||||
|
for(auto i = 0; i < men.size(); i++){
|
||||||
|
if(men.at(i)->deaf())
|
||||||
|
totalDeaf++;
|
||||||
|
}
|
||||||
|
for(auto i = 0; i < women.size(); i++){
|
||||||
|
if(women.at(i)->deaf())
|
||||||
|
totalDeaf++;
|
||||||
|
}
|
||||||
|
outputFile<<"\t"<<totalDeaf;
|
||||||
|
|
||||||
|
int sumMarriages = marriageDD + marriageDH + marriageHH;
|
||||||
|
int sumChildren = newMen.size() + newWomen.size();
|
||||||
|
outputFile<<"\t"<<float(marriageDD)/sumMarriages;
|
||||||
|
outputFile<<"\t"<<float(childrenDD)/sumChildren;
|
||||||
|
outputFile<<"\t"<<float(marriageDH)/sumMarriages;
|
||||||
|
outputFile<<"\t"<<float(childrenDH)/sumChildren;
|
||||||
|
outputFile<<"\t"<<float(marriageHH)/sumMarriages;
|
||||||
|
outputFile<<"\t"<<float(childrenHH)/sumChildren;
|
||||||
|
|
||||||
|
int deafAllelesTotal = 0;
|
||||||
|
int deafHomoz = 0;
|
||||||
|
for(unsigned int i = 0; i< men.size(); i++){
|
||||||
|
int deafAlleles = men.at(i)->getDeafAllelesCount();
|
||||||
|
deafAllelesTotal += deafAlleles;
|
||||||
|
//int increase = deafAllelesTotal == 2 ? 1 : 0;
|
||||||
|
deafHomoz += deafAlleles/2;
|
||||||
|
}
|
||||||
|
for(unsigned int i = 0; i< women.size(); i++){
|
||||||
|
int deafAlleles = women.at(i)->getDeafAllelesCount();
|
||||||
|
deafAllelesTotal += deafAlleles;
|
||||||
|
//int increase = deafAllelesTotal == 2 ? 1 : 0;
|
||||||
|
deafHomoz += deafAlleles/2;
|
||||||
|
}
|
||||||
|
|
||||||
|
outputFile<<"\t"<<float(deafAllelesTotal)/(2*totalP);
|
||||||
|
outputFile<<"\t"<<float(deafHomoz)/totalP;
|
||||||
|
/*
|
||||||
|
outputFile<<"\tDA frequency\tDA homozygotes frequency";
|
||||||
|
*/
|
||||||
|
outputFile<<"\n";
|
||||||
|
|
||||||
|
std::cout<<"Done\n";
|
||||||
|
|
||||||
|
std::cout<<"\tDeleting old agents\t";
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
for(int i = 0; i < men.size(); i++){
|
||||||
|
delete men.at(i);
|
||||||
|
}
|
||||||
|
for(int i = 0; i < women.size(); i++){
|
||||||
|
delete women.at(i);
|
||||||
|
}
|
||||||
|
std::cout<<"Done\n";
|
||||||
|
|
||||||
|
std::cout<<"\tReplacing old by new and shuffling\t";
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
men = newMen;
|
||||||
|
women = newWomen;
|
||||||
|
std::random_shuffle(men.begin(), men.end());
|
||||||
|
std::random_shuffle(women.begin(), women.end());
|
||||||
|
|
||||||
|
std::cout<<"Done\n";
|
||||||
|
std::cout<<"\tClearing\t";
|
||||||
|
newMen.clear();
|
||||||
|
newWomen.clear();
|
||||||
|
std::cout<<"Done\n";
|
||||||
|
|
||||||
|
} // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||||
|
outputFile.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
float Processor::esteem(Agent* man, Agent* woman){
|
||||||
|
float ans = 0.0f;
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
if( (man->getFatherID() == woman->getFatherID() ||
|
||||||
|
man->getMotherID() == woman->getMotherID()) && woman->getMotherID() != -1){
|
||||||
|
return -50.f;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(man->deaf() == woman->deaf()){
|
||||||
|
if(man->deaf()){
|
||||||
|
ans += 2*Settings::WEIGHT_PHENO_D;
|
||||||
|
float sum1 = man->knowsSign() ? Settings::WEIGHT_SIGN_D : 0;
|
||||||
|
float sum2 = woman->knowsSign() ? Settings::WEIGHT_SIGN_D : 0;
|
||||||
|
ans += sum1+sum2;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
ans += 2*Settings::WEIGHT_PHENO_H;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(man->knowsSign() && woman->knowsSign()){
|
||||||
|
ans += Settings::WEIGHT_SIGN_D + Settings::WEIGHT_SIGN_H;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(man->getSocialP() + woman->getSocialP() > ans)
|
||||||
|
return 0.0f;
|
||||||
|
|
||||||
|
return ans;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Processor::initSettings(std::string fileName){
|
||||||
|
std::vector<std::string> script;
|
||||||
|
// std::ifstream file(fileName.c_str());
|
||||||
|
// std::string str;
|
||||||
|
|
||||||
|
// while(getline(file,str)){
|
||||||
|
// if(str.length() > 2)
|
||||||
|
// script.push_back(str);
|
||||||
|
// }
|
||||||
|
// file.close();
|
||||||
|
|
||||||
|
// process Script
|
||||||
|
unsigned int curLine;
|
||||||
|
for(curLine = 0; curLine < script.size(); curLine++){
|
||||||
|
if(script.at(curLine).at(0) == '/' || script.at(curLine).at(0) == '#')
|
||||||
|
continue;
|
||||||
|
|
||||||
|
std::vector<std::string > tokensVector; // Search for tokens
|
||||||
|
//boost::split(tokensVector, script.at(curLine), boost::is_any_of("=") );
|
||||||
|
boost::split(tokensVector, script.at(curLine), std::bind2nd(std::equal_to<char>(), '='));
|
||||||
|
|
||||||
|
std::string instr = tokensVector.at(0);
|
||||||
|
boost::to_lower(instr);
|
||||||
|
boost::trim(instr);
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
if(instr == "generations" || instr == "iterations" ){
|
||||||
|
int iter = Settings::MAX_GENERATIONS;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%d", &iter);
|
||||||
|
Settings::MAX_GENERATIONS = iter;
|
||||||
|
}
|
||||||
|
if(instr == "init_pop_men"){
|
||||||
|
int pop = Settings::INIT_POP_SIZE_M;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%d", &pop);
|
||||||
|
Settings::INIT_POP_SIZE_M = pop;
|
||||||
|
}
|
||||||
|
if(instr == "init_pop_women"){
|
||||||
|
int pop = Settings::INIT_POP_SIZE_W;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%d", &pop);
|
||||||
|
Settings::INIT_POP_SIZE_W = pop;
|
||||||
|
}
|
||||||
|
if(instr == "candidate_pairs_mean"){
|
||||||
|
int cand = Settings::CANDIDATE_PAIRS_MEAN;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%d", &cand);
|
||||||
|
Settings::CANDIDATE_PAIRS_MEAN = cand;
|
||||||
|
}
|
||||||
|
if(instr == "candidate_pairs_var"){
|
||||||
|
int cand = Settings::CANDIDATE_PAIRS_VAR;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%d", &cand);
|
||||||
|
Settings::CANDIDATE_PAIRS_VAR = cand;
|
||||||
|
}
|
||||||
|
else if(instr == "spontaneous_deaf"){
|
||||||
|
float deaf = Settings::SPONTANEOUS_DEAF;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%f", &deaf);
|
||||||
|
Settings::SPONTANEOUS_DEAF = deaf;
|
||||||
|
}
|
||||||
|
else if(instr == "deaf_allele_ratio"){
|
||||||
|
float deaf = Settings::DEAF_ALLELE_RATIO;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%f", &deaf);
|
||||||
|
Settings::DEAF_ALLELE_RATIO = deaf;
|
||||||
|
}
|
||||||
|
else if(instr == "deaf_homozygotes"){
|
||||||
|
float deaf = Settings::DEAF_HOMOZYGOTES;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%f", &deaf);
|
||||||
|
Settings::DEAF_HOMOZYGOTES = deaf;
|
||||||
|
}
|
||||||
|
else if(instr == "hear_homozygotes"){
|
||||||
|
float hear = Settings::HEAR_HOMOZYGOTES;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%f", &hear);
|
||||||
|
Settings::HEAR_HOMOZYGOTES = hear;
|
||||||
|
}
|
||||||
|
else if(instr == "birth_rate_hearing" || instr == "birth_rate_h"){
|
||||||
|
float rate = Settings::BIRTH_RATE_H;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%f", &rate);
|
||||||
|
Settings::BIRTH_RATE_H = rate;
|
||||||
|
}
|
||||||
|
else if(instr == "birth_rate_deaf" || instr == "birth_rate_d"){
|
||||||
|
float rate = Settings::BIRTH_RATE_D;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%f", &rate);
|
||||||
|
Settings::BIRTH_RATE_D = rate;
|
||||||
|
}
|
||||||
|
else if(instr == "beta_a"){
|
||||||
|
float rate = Settings::BETA_A;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%f", &rate);
|
||||||
|
Settings::BETA_A = rate;
|
||||||
|
}
|
||||||
|
else if(instr == "beta_b"){
|
||||||
|
float rate = Settings::BETA_B;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%f", &rate);
|
||||||
|
Settings::BETA_B = rate;
|
||||||
|
}
|
||||||
|
else if(instr == "social_mean_h" || instr == "social_mean_hearing"){
|
||||||
|
float rate = Settings::SOCIAL_MEAN_H;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%f", &rate);
|
||||||
|
Settings::SOCIAL_MEAN_H = rate;
|
||||||
|
}
|
||||||
|
else if(instr == "social_mean_d" || instr == "social_mean_deaf"){
|
||||||
|
float rate = Settings::SOCIAL_MEAN_D;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%f", &rate);
|
||||||
|
Settings::SOCIAL_MEAN_D = rate;
|
||||||
|
}
|
||||||
|
else if(instr == "social_var_h" || instr == "social_var_hearing"){
|
||||||
|
float rate = Settings::SOCIAL_VAR_H;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%f", &rate);
|
||||||
|
Settings::SOCIAL_VAR_H = rate;
|
||||||
|
}
|
||||||
|
else if(instr == "social_var_d" || instr == "social_var_deaf"){
|
||||||
|
float rate = Settings::SOCIAL_VAR_D;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%f", &rate);
|
||||||
|
Settings::SOCIAL_VAR_D = rate;
|
||||||
|
}
|
||||||
|
else if(instr == "weight_phenotype_hearing" || instr == "weight_pheno_h"){
|
||||||
|
float rate = Settings::WEIGHT_PHENO_H;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%f", &rate);
|
||||||
|
Settings::WEIGHT_PHENO_H = rate;
|
||||||
|
}
|
||||||
|
else if(instr == "weight_phenotype_deaf" || instr == "weight_pheno_d"){
|
||||||
|
float rate = Settings::WEIGHT_PHENO_D;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%f", &rate);
|
||||||
|
Settings::WEIGHT_PHENO_D = rate;
|
||||||
|
}
|
||||||
|
else if(instr == "weight_sign_h" || instr == "weight_sign_hearing"){
|
||||||
|
float rate = Settings::WEIGHT_SIGN_H;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%f", &rate);
|
||||||
|
Settings::WEIGHT_SIGN_H = rate;
|
||||||
|
}
|
||||||
|
else if(instr == "weight_sign_d" || instr == "weight_sign_deaf"){
|
||||||
|
float rate = Settings::WEIGHT_SIGN_D;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%f", &rate);
|
||||||
|
Settings::WEIGHT_SIGN_D = rate;
|
||||||
|
}
|
||||||
|
else if(instr == "sign_lang_d" || instr == "sign_lang_deaf"){
|
||||||
|
float rate = Settings::SIGN_LANG_DEAF;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%f", &rate);
|
||||||
|
Settings::SIGN_LANG_DEAF = rate;
|
||||||
|
}
|
||||||
|
else if(instr == "sign_lang_h" || instr == "sign_lang_hear"){
|
||||||
|
float rate = Settings::SIGN_LANG_HEAR;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%f", &rate);
|
||||||
|
Settings::SIGN_LANG_HEAR = rate;
|
||||||
|
}
|
||||||
|
else if(instr == "output" || instr == "output_file"){
|
||||||
|
std::string file = tokensVector.at(1);
|
||||||
|
boost::trim(file);
|
||||||
|
Settings::OUTPUT_FILE = file;
|
||||||
|
}
|
||||||
|
/*if(instr == "fullstat"){
|
||||||
|
int flag = 0;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%d", &flag);
|
||||||
|
if(flag != 0)
|
||||||
|
Settings::WRITE_FULL_STATISTICS_TO_FILE = true;
|
||||||
|
}*/
|
||||||
|
/*else if(instr == "birth" || instr == "birthrate" || instr == "birth_rate" ){
|
||||||
|
double rate = Settings::BirthRate;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%lg", &rate);
|
||||||
|
Settings::BirthRate = rate;
|
||||||
|
}*/
|
||||||
|
} // (END) for(curLine = 0; curLine < script.size(); curLine++)
|
||||||
|
|
||||||
|
}
|
||||||
11
Deaf2.0/Deaf2.0/Processor.h
Normal file
11
Deaf2.0/Deaf2.0/Processor.h
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Agent.h"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
class Processor{
|
||||||
|
public:
|
||||||
|
// Processor();
|
||||||
|
void run(std::string file = "");
|
||||||
|
void initSettings(std::string file);
|
||||||
|
float esteem(Agent*, Agent*);
|
||||||
|
};
|
||||||
39
Deaf2.0/Deaf2.0/Settings.cpp
Normal file
39
Deaf2.0/Deaf2.0/Settings.cpp
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
#include "Settings.h"
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
|
int Settings::MAX_GENERATIONS = 10;
|
||||||
|
int Settings::INIT_POP_SIZE_M = 5000;
|
||||||
|
int Settings::INIT_POP_SIZE_W = 5000;
|
||||||
|
|
||||||
|
int Settings::CANDIDATE_PAIRS_MEAN = 100;
|
||||||
|
int Settings::CANDIDATE_PAIRS_VAR = 30;
|
||||||
|
|
||||||
|
float Settings::SPONTANEOUS_DEAF = 0.001f;
|
||||||
|
float Settings::DEAF_ALLELE_RATIO = 0.1f;
|
||||||
|
float Settings::DEAF_HOMOZYGOTES = 0.05f;
|
||||||
|
float Settings::HEAR_HOMOZYGOTES = 0.65f;
|
||||||
|
|
||||||
|
float Settings::BIRTH_RATE_H = 2.3f; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
float Settings::BIRTH_RATE_D = 2.1f; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
float Settings::BETA_A = 2.0f;
|
||||||
|
float Settings::BETA_B = 5.0f;
|
||||||
|
|
||||||
|
float Settings::SOCIAL_MEAN_H = 0.3f;
|
||||||
|
float Settings::SOCIAL_VAR_H = 0.05f;
|
||||||
|
float Settings::SOCIAL_MEAN_D = 0.3f;
|
||||||
|
float Settings::SOCIAL_VAR_D = 0.05f;
|
||||||
|
|
||||||
|
float Settings::WEIGHT_PHENO_H = 0.7f;
|
||||||
|
float Settings::WEIGHT_SIGN_H = 0.3f;
|
||||||
|
float Settings::WEIGHT_PHENO_D = 0.58f;
|
||||||
|
float Settings::WEIGHT_SIGN_D = 0.42f;
|
||||||
|
|
||||||
|
float Settings::SIGN_LANG_DEAF = 0.8f;
|
||||||
|
float Settings::SIGN_LANG_HEAR = 0.01f;
|
||||||
|
|
||||||
|
std::default_random_engine Settings::RANDOM_GENERATOR(time(0));
|
||||||
|
|
||||||
|
int Settings::DEAF_COMMUNITY_MODEL = 1;
|
||||||
|
|
||||||
|
std::string Settings::OUTPUT_FILE = "output.deaf2.0.csv";
|
||||||
43
Deaf2.0/Deaf2.0/Settings.h
Normal file
43
Deaf2.0/Deaf2.0/Settings.h
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <string>
|
||||||
|
#include <random>
|
||||||
|
|
||||||
|
class Settings{
|
||||||
|
public:
|
||||||
|
static int MAX_GENERATIONS;
|
||||||
|
static int INIT_POP_SIZE_M;
|
||||||
|
static int INIT_POP_SIZE_W;
|
||||||
|
|
||||||
|
static int CANDIDATE_PAIRS_MEAN;
|
||||||
|
static int CANDIDATE_PAIRS_VAR;
|
||||||
|
|
||||||
|
static float SPONTANEOUS_DEAF;
|
||||||
|
static float DEAF_ALLELE_RATIO;
|
||||||
|
static float DEAF_HOMOZYGOTES;
|
||||||
|
static float HEAR_HOMOZYGOTES;
|
||||||
|
|
||||||
|
static float BIRTH_RATE_H; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
static float BIRTH_RATE_D; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
static float BETA_A;
|
||||||
|
static float BETA_B;
|
||||||
|
|
||||||
|
static float SOCIAL_MEAN_H;
|
||||||
|
static float SOCIAL_VAR_H;
|
||||||
|
static float SOCIAL_MEAN_D;
|
||||||
|
static float SOCIAL_VAR_D;
|
||||||
|
|
||||||
|
static float WEIGHT_PHENO_H;
|
||||||
|
static float WEIGHT_SIGN_H;
|
||||||
|
static float WEIGHT_PHENO_D;
|
||||||
|
static float WEIGHT_SIGN_D;
|
||||||
|
|
||||||
|
static float SIGN_LANG_DEAF;
|
||||||
|
static float SIGN_LANG_HEAR;
|
||||||
|
|
||||||
|
static std::default_random_engine RANDOM_GENERATOR;
|
||||||
|
|
||||||
|
static int DEAF_COMMUNITY_MODEL; // 0 - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>, 1 - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, 2 - <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
static std::string OUTPUT_FILE;
|
||||||
|
};
|
||||||
35
Makefile
Normal file
35
Makefile
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
CXX = g++
|
||||||
|
CXXFLAGS = -O2 -g -Wall -fmessage-length=0
|
||||||
|
CXXFLAGS = -std=gnu++11 -O2 -Wall -fmessage-length=0
|
||||||
|
|
||||||
|
#OBJS = DEC-0.0.o
|
||||||
|
|
||||||
|
SRCS = Agent.cpp
|
||||||
|
SRCS += Main.cpp
|
||||||
|
SRCS += Processor.cpp
|
||||||
|
SRCS += Settings.cpp
|
||||||
|
#SRCS +=
|
||||||
|
|
||||||
|
OBJS+= ${SRCS:.cpp=.o}
|
||||||
|
|
||||||
|
.SUFFIXES : .cpp
|
||||||
|
%.o : %.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
|
||||||
|
LIBS = -lboost_random
|
||||||
|
|
||||||
|
TARGET = Deaf-2.0
|
||||||
|
|
||||||
|
$(TARGET): $(OBJS)
|
||||||
|
$(CXX) -o $(TARGET) $(OBJS) $(LIBS)
|
||||||
|
|
||||||
|
all: $(TARGET)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(OBJS) $(TARGET)
|
||||||
|
|
||||||
|
|
||||||
|
#LDFLAGS = -lm #-Lutil -Lutil/stemloop -Lutil/tscore
|
||||||
|
#FORTCFLAGS =
|
||||||
|
|
||||||
710
Processor.cpp
Normal file
710
Processor.cpp
Normal file
@@ -0,0 +1,710 @@
|
|||||||
|
#include "Agent.h"
|
||||||
|
#include "Processor.h"
|
||||||
|
#include "Settings.h"
|
||||||
|
#include <random>
|
||||||
|
#include <ctime>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
|
#include <boost/algorithm/string.hpp>
|
||||||
|
#include <boost/tokenizer.hpp>
|
||||||
|
#include <boost/math/distributions/beta.hpp>
|
||||||
|
#include <boost/random/random_device.hpp>
|
||||||
|
#include <boost/random/uniform_real_distribution.hpp>
|
||||||
|
|
||||||
|
#define sscanf_s scanf
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
boost::random::random_device rng;
|
||||||
|
boost::random::uniform_real_distribution<> uniform(0,1);
|
||||||
|
|
||||||
|
void Processor::run(std::string fileName){
|
||||||
|
|
||||||
|
if(fileName.size() > 1){
|
||||||
|
this->initSettings(fileName);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
this->initSettings("C:/Deafness modelling/Deaf2.0 20.11.18/INIT.txt");
|
||||||
|
//Settings::OUTPUT_FILE = "D:/model/Deaf2.0 by Sergey 06.08/OUTPUT/output.deaf25.txt";
|
||||||
|
}
|
||||||
|
int initPopSizeM = Settings::INIT_POP_SIZE_M;
|
||||||
|
int initPopSizeW = Settings::INIT_POP_SIZE_W;
|
||||||
|
///float deafAlleleRatio = Settings::DEAF_ALLELE_RATIO;
|
||||||
|
|
||||||
|
float birthRateH = Settings::BIRTH_RATE_H; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
float birthRateD = Settings::BIRTH_RATE_D; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
int maxGenerations = Settings::MAX_GENERATIONS;
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
std::cout<<"Initializing output file..\t";
|
||||||
|
std::ofstream outputFile(Settings::OUTPUT_FILE);
|
||||||
|
outputFile<<"Generation\tTotalPopulation\tMen\tWomen\tDeaf";
|
||||||
|
outputFile<<"\tDD marriages\tDD children";
|
||||||
|
outputFile<<"\tDH marriages\tDH children";
|
||||||
|
outputFile<<"\tHH marriages\tHH children";
|
||||||
|
outputFile<<"\tDA frequency\tDA homozygotes frequency";
|
||||||
|
// TODO <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||||
|
outputFile<<std::endl;
|
||||||
|
std::cout<<"Done\n";
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
//std::vector<std::vector<float> > matrixCurrent;
|
||||||
|
//std::vector<std::vector<float> > matrixFuture;
|
||||||
|
|
||||||
|
std::vector<Agent*> men;
|
||||||
|
std::vector<Agent*> women;
|
||||||
|
std::vector<Agent*> newMen;
|
||||||
|
std::vector<Agent*> newWomen;
|
||||||
|
|
||||||
|
std::default_random_engine& generator = Settings::RANDOM_GENERATOR;
|
||||||
|
//generator.seed(std::time(0));
|
||||||
|
//RandomDevice::RandomDevice(unsigned long n) : rand_seed(n), engine(n){ }
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
std::cout<<"Creating men..("<<initPopSizeM<<")\t";
|
||||||
|
int deafHomozygotes = (int) (initPopSizeM*Settings::DEAF_HOMOZYGOTES);
|
||||||
|
int hearHomozygotes = (int) (initPopSizeM*Settings::HEAR_HOMOZYGOTES);
|
||||||
|
int heterozygores = initPopSizeM - deafHomozygotes - hearHomozygotes;
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
||||||
|
for(int i = 0; i < hearHomozygotes; i++){
|
||||||
|
bool isDeaf = false;
|
||||||
|
int alleleFather = 0;
|
||||||
|
int alleleMother = 0;
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
std::uniform_real_distribution<float> distrUI(0.f,1.f);
|
||||||
|
if(distrUI(generator) < Settings::SPONTANEOUS_DEAF)
|
||||||
|
isDeaf = true;
|
||||||
|
|
||||||
|
float mean = isDeaf ? Settings::SOCIAL_MEAN_D : Settings::SOCIAL_MEAN_H;
|
||||||
|
float sigma= isDeaf ? Settings::SOCIAL_VAR_D : Settings::SOCIAL_VAR_H;
|
||||||
|
std::normal_distribution<float> distN(mean, sigma);
|
||||||
|
float socialP = distN(generator);
|
||||||
|
|
||||||
|
float signLangLevel = isDeaf ? Settings::SIGN_LANG_DEAF : Settings::SIGN_LANG_HEAR;
|
||||||
|
bool signL = distrUI(generator) < signLangLevel ? true: false;
|
||||||
|
|
||||||
|
Agent* a = new Agent(alleleFather, alleleMother, isDeaf, signL, socialP);
|
||||||
|
men.push_back(a);
|
||||||
|
} // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
||||||
|
for(int i = 0; i < heterozygores; i++){
|
||||||
|
bool isDeaf = false;
|
||||||
|
int alleleFather = 1; // TODO: <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
int alleleMother = 0;
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
std::uniform_real_distribution<float> distrUI(0.f,1.f);
|
||||||
|
if(distrUI(generator) < Settings::SPONTANEOUS_DEAF)
|
||||||
|
isDeaf = true;
|
||||||
|
|
||||||
|
float mean = isDeaf ? Settings::SOCIAL_MEAN_D : Settings::SOCIAL_MEAN_H;
|
||||||
|
float sigma= isDeaf ? Settings::SOCIAL_VAR_D : Settings::SOCIAL_VAR_H;
|
||||||
|
std::normal_distribution<float> distN(mean, sigma);
|
||||||
|
float socialP = distN(generator);
|
||||||
|
|
||||||
|
float signLangLevel = isDeaf ? Settings::SIGN_LANG_DEAF : Settings::SIGN_LANG_HEAR;
|
||||||
|
bool signL = distrUI(generator) < signLangLevel ? true: false;
|
||||||
|
|
||||||
|
Agent* a = new Agent(alleleFather, alleleMother, isDeaf, signL, socialP);
|
||||||
|
men.push_back(a);
|
||||||
|
} // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
for(int i = 0; i < deafHomozygotes; i++){
|
||||||
|
bool isDeaf = true;
|
||||||
|
int alleleFather = 1;
|
||||||
|
int alleleMother = 1;
|
||||||
|
|
||||||
|
float mean = isDeaf ? Settings::SOCIAL_MEAN_D : Settings::SOCIAL_MEAN_H;
|
||||||
|
float sigma= isDeaf ? Settings::SOCIAL_VAR_D : Settings::SOCIAL_VAR_H;
|
||||||
|
std::normal_distribution<float> distN(mean, sigma);
|
||||||
|
float socialP = distN(generator);
|
||||||
|
|
||||||
|
std::uniform_real_distribution<float> distrUI(0.f,1.f);
|
||||||
|
float signLangLevel = isDeaf ? Settings::SIGN_LANG_DEAF : Settings::SIGN_LANG_HEAR;
|
||||||
|
bool signL = distrUI(generator) < signLangLevel ? true: false;
|
||||||
|
|
||||||
|
Agent* a = new Agent(alleleFather, alleleMother, isDeaf, signL, socialP);
|
||||||
|
men.push_back(a);
|
||||||
|
}// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
std::random_shuffle(men.begin(), men.end());
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
std::cout<<"Done\n";
|
||||||
|
|
||||||
|
std::cout<<"Creating women..\t";
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
deafHomozygotes = (int) (initPopSizeW*Settings::DEAF_HOMOZYGOTES);
|
||||||
|
hearHomozygotes = (int) (initPopSizeW*Settings::HEAR_HOMOZYGOTES);
|
||||||
|
heterozygores = initPopSizeW - deafHomozygotes - hearHomozygotes;
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
||||||
|
for(int i = 0; i < hearHomozygotes; i++){
|
||||||
|
bool isDeaf = false;
|
||||||
|
int alleleFather = 0;
|
||||||
|
int alleleMother = 0;
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
std::uniform_real_distribution<float> distrUI(0.f,1.f);
|
||||||
|
if(distrUI(generator) < Settings::SPONTANEOUS_DEAF)
|
||||||
|
isDeaf = true;
|
||||||
|
|
||||||
|
float mean = isDeaf ? Settings::SOCIAL_MEAN_D : Settings::SOCIAL_MEAN_H;
|
||||||
|
float sigma= isDeaf ? Settings::SOCIAL_VAR_D : Settings::SOCIAL_VAR_H;
|
||||||
|
std::normal_distribution<float> distN(mean, sigma);
|
||||||
|
float socialP = distN(generator);
|
||||||
|
|
||||||
|
float signLangLevel = isDeaf ? Settings::SIGN_LANG_DEAF : Settings::SIGN_LANG_HEAR;
|
||||||
|
bool signL = distrUI(generator) < signLangLevel ? true: false;
|
||||||
|
|
||||||
|
Agent* a = new Agent(alleleFather, alleleMother, isDeaf, signL, socialP);
|
||||||
|
women.push_back(a);
|
||||||
|
} // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
||||||
|
for(int i = 0; i < heterozygores; i++){
|
||||||
|
bool isDeaf = false;
|
||||||
|
int alleleFather = 1; // TODO: <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
int alleleMother = 0;
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
std::uniform_real_distribution<float> distrUI(0.f,1.f);
|
||||||
|
if(distrUI(generator) < Settings::SPONTANEOUS_DEAF)
|
||||||
|
isDeaf = true;
|
||||||
|
|
||||||
|
float mean = isDeaf ? Settings::SOCIAL_MEAN_D : Settings::SOCIAL_MEAN_H;
|
||||||
|
float sigma= isDeaf ? Settings::SOCIAL_VAR_D : Settings::SOCIAL_VAR_H;
|
||||||
|
std::normal_distribution<float> distN(mean, sigma);
|
||||||
|
float socialP = distN(generator);
|
||||||
|
|
||||||
|
float signLangLevel = isDeaf ? Settings::SIGN_LANG_DEAF : Settings::SIGN_LANG_HEAR;
|
||||||
|
bool signL = distrUI(generator) < signLangLevel ? true: false;
|
||||||
|
|
||||||
|
Agent* a = new Agent(alleleFather, alleleMother, isDeaf, signL, socialP);
|
||||||
|
women.push_back(a);
|
||||||
|
} // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
for(int i = 0; i < deafHomozygotes; i++){
|
||||||
|
bool isDeaf = true;
|
||||||
|
int alleleFather = 1;
|
||||||
|
int alleleMother = 1;
|
||||||
|
|
||||||
|
float mean = isDeaf ? Settings::SOCIAL_MEAN_D : Settings::SOCIAL_MEAN_H;
|
||||||
|
float sigma= isDeaf ? Settings::SOCIAL_VAR_D : Settings::SOCIAL_VAR_H;
|
||||||
|
std::normal_distribution<float> distN(mean, sigma);
|
||||||
|
float socialP = distN(generator);
|
||||||
|
|
||||||
|
std::uniform_real_distribution<float> distrUI(0.f,1.f);
|
||||||
|
float signLangLevel = isDeaf ? Settings::SIGN_LANG_DEAF : Settings::SIGN_LANG_HEAR;
|
||||||
|
bool signL = distrUI(generator) < signLangLevel ? true: false;
|
||||||
|
|
||||||
|
Agent* a = new Agent(alleleFather, alleleMother, isDeaf, signL, socialP);
|
||||||
|
women.push_back(a);
|
||||||
|
}// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
std::random_shuffle(women.begin(), women.end());
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
std::cout<<"Done\n";
|
||||||
|
|
||||||
|
std::cout<<"\nMain cycle\n";
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||||
|
for(int gen = 0; gen < maxGenerations; gen++){
|
||||||
|
std::cout<<"Generation\t"<<gen<<"\n";
|
||||||
|
int marriageDD = 0;
|
||||||
|
int marriageDH = 0;
|
||||||
|
int marriageHH = 0;
|
||||||
|
int childrenDD = 0;
|
||||||
|
int childrenDH = 0;
|
||||||
|
int childrenHH = 0;
|
||||||
|
|
||||||
|
std::cout<<"\tInitializing matrixCurrent\t";
|
||||||
|
//std::vector<float> vect(women.size(),0.0f);
|
||||||
|
//matrixCurrent.assign(men.size(),vect);
|
||||||
|
std::cout<<"\tDone\n";
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD> <<3C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>
|
||||||
|
std::cout<<"\tInitializing settledPairs\t";
|
||||||
|
std::uniform_real_distribution<float> distrUI(0.f,1.f);
|
||||||
|
std::cout<<".";
|
||||||
|
std::vector<std::vector<std::pair<unsigned int,float> > > settledPairs(men.size());
|
||||||
|
std::cout<<".";
|
||||||
|
for(int i = 0; i < settledPairs.size(); i++){
|
||||||
|
float f = distrUI(generator);
|
||||||
|
int sign = f < 0.5f ? -1 : 1;
|
||||||
|
int candidatePairs = Settings::CANDIDATE_PAIRS_MEAN
|
||||||
|
+ (int)(sign*f*Settings::CANDIDATE_PAIRS_VAR);
|
||||||
|
|
||||||
|
// TODO: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
int left = i - candidatePairs/2;
|
||||||
|
int right = i + candidatePairs/2;
|
||||||
|
|
||||||
|
// HACK: 2018/11/23 <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
if(Settings::DEAF_COMMUNITY_MODEL == 1){
|
||||||
|
left = 0;
|
||||||
|
right = women.size() - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(left < 0){
|
||||||
|
right -= left;
|
||||||
|
left = 0;
|
||||||
|
}
|
||||||
|
if(right >= women.size()){
|
||||||
|
right = women.size() - 1;
|
||||||
|
left = right - candidatePairs;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::pair<unsigned int,float> > pairs(candidatePairs);
|
||||||
|
for(unsigned int p = 0; p < pairs.size(); p++){
|
||||||
|
pairs.at(p).first = left;
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>-<2D><><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
//matrixCurrent.at(i).at(left)
|
||||||
|
pairs.at(p).second = esteem(men.at(i),women.at(left));
|
||||||
|
left++;
|
||||||
|
}
|
||||||
|
settledPairs.at(i) = pairs;
|
||||||
|
}
|
||||||
|
// (END) <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
std::cout<<"Done\n";
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
// <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
/*for(unsigned int m = 0; m < men.size(); m++){
|
||||||
|
// <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
for(unsigned int w = 0; w < women.size(); w++){
|
||||||
|
if(matrixCurrent.at(m).at(w) >= 0.0f)
|
||||||
|
matrixCurrent.at(m).at(w) = esteem(men.at(m),women.at(w));
|
||||||
|
}
|
||||||
|
} */
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
/* std::cout<<"\tGenerating offsprings\t";
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
// <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
std::cout << "MENS" << std::endl;
|
||||||
|
for (auto m = 0; m < settledPairs.size(); ++m)
|
||||||
|
{
|
||||||
|
std::cout << "MEN: " << m << ": ";
|
||||||
|
for (auto w = 0; w < settledPairs[m].size(); ++w)
|
||||||
|
{
|
||||||
|
std::cout << settledPairs[m][w].first << " : " << settledPairs[m][w].second << "; ";
|
||||||
|
}
|
||||||
|
std::cout << std::endl;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
for(int m = 0; m < men.size(); m++){
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
int bestW = 0;
|
||||||
|
float bestScore = 0.0f;
|
||||||
|
|
||||||
|
/* <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
for(int w = 0; w < women.size(); w++){
|
||||||
|
if(matrixCurrent.at(m).at(w) > bestScore){
|
||||||
|
bestScore = matrixCurrent.at(m).at(w);
|
||||||
|
bestW = w;
|
||||||
|
}
|
||||||
|
} // <20><><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
**/
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for(unsigned int p = 0; p < settledPairs.at(m).size(); p++){
|
||||||
|
unsigned int w = settledPairs.at(m).at(p).first;
|
||||||
|
|
||||||
|
if(women.at(w)->alreadyMarried)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if(settledPairs.at(m).at(p).second/*matrixCurrent.at(m).at(w)*/ > bestScore){
|
||||||
|
bestScore = settledPairs.at(m).at(p).second; //matrixCurrent.at(m).at(w);
|
||||||
|
bestW = w;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// (END) <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
if(bestScore <= 0.0f)
|
||||||
|
continue; // <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
int* mariage = &marriageHH;
|
||||||
|
int* childrenType = &childrenHH;
|
||||||
|
|
||||||
|
float meanChildren = birthRateH;
|
||||||
|
if((men.at(m)->deaf() && !women.at(bestW)->deaf()) ||
|
||||||
|
(!men.at(m)->deaf() && women.at(bestW)->deaf())){
|
||||||
|
mariage = &marriageDH;
|
||||||
|
childrenType = &childrenDH;
|
||||||
|
}
|
||||||
|
if(men.at(m)->deaf() && women.at(bestW)->deaf()){
|
||||||
|
mariage = &marriageDD;
|
||||||
|
childrenType = &childrenDD;
|
||||||
|
}
|
||||||
|
if(men.at(m)->deaf() || women.at(bestW)->deaf()){
|
||||||
|
meanChildren = birthRateD;
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::math::beta_distribution<> distrB(Settings::BETA_A,Settings::BETA_B);
|
||||||
|
float correction = (Settings::BETA_A+Settings::BETA_B)/Settings::BETA_A*meanChildren;
|
||||||
|
// FOR WINDOWS float fChildren = distrB(generator)*correction; //
|
||||||
|
float fChildren = quantile(distrB, uniform(rng)) * correction;
|
||||||
|
int children = (int) std::floor(fChildren+0.5f);
|
||||||
|
|
||||||
|
(*mariage)++;
|
||||||
|
(*childrenType) += children;
|
||||||
|
|
||||||
|
// TODO: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> + <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||||
|
std::vector<Agent*> newSibs; // <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
std::vector<Agent*> deafSibs;// <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
for(int i = 0; i < children; i++){
|
||||||
|
Agent* newAgent = new Agent(men.at(m), m, women.at(bestW), bestW);
|
||||||
|
newSibs.push_back(newAgent);
|
||||||
|
if(newAgent->deaf()){
|
||||||
|
deafSibs.push_back(newAgent);
|
||||||
|
}
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
std::uniform_int_distribution<int> distrUI(0,1);
|
||||||
|
if(distrUI(generator) == 0){
|
||||||
|
newMen.push_back(newAgent);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
newWomen.push_back(newAgent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1 - <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD>-<2D><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
if(men.at(m)->deaf() || women.at(bestW)->deaf()){
|
||||||
|
if(men.at(m)->knowsSign() || women.at(bestW)->knowsSign()){
|
||||||
|
for(auto i = 0; i < newSibs.size(); i++){
|
||||||
|
newSibs.at(i)->teachSignLanguage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2 - <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
else if(deafSibs.size() > 0){
|
||||||
|
std::uniform_real_distribution<float> distrUF(0.f,1.f);
|
||||||
|
// <20>) <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||||
|
bool sibsKnowSL = false;
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
for(auto i = 0; i < deafSibs.size(); i++){
|
||||||
|
if(distrUF(generator) <= Settings::SIGN_LANG_DEAF){
|
||||||
|
deafSibs.at(i)->teachSignLanguage();
|
||||||
|
sibsKnowSL = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
for(auto i = 0; i < newSibs.size(); i++){
|
||||||
|
if(!newSibs.at(i)->deaf() && distrUF(generator) <= Settings::SIGN_LANG_HEAR){
|
||||||
|
newSibs.at(i)->teachSignLanguage();
|
||||||
|
sibsKnowSL = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// <20>) <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
if(men.at(m)->knowsSign() || women.at(bestW)->knowsSign() || sibsKnowSL){
|
||||||
|
for(auto i = 0; i < newSibs.size(); i++){
|
||||||
|
newSibs.at(i)->teachSignLanguage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 3 - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
else {
|
||||||
|
std::uniform_real_distribution<float> distrUF(0.f,1.f);
|
||||||
|
for(auto i = 0; i < newSibs.size(); i++){
|
||||||
|
if(distrUF(generator) <= Settings::SIGN_LANG_HEAR){
|
||||||
|
newSibs.at(i)->teachSignLanguage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// (END) <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
women.at(bestW)->alreadyMarried = true;
|
||||||
|
//for(int i = m; i < men.size(); i++){
|
||||||
|
// matrixCurrent.at(i).at(bestW) = -100.0f;
|
||||||
|
//}
|
||||||
|
} // <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
std::cout<<"Done\n";
|
||||||
|
|
||||||
|
std::cout<<"\tSaving model state\t";
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
int totalP = men.size()+women.size();
|
||||||
|
outputFile<<gen;
|
||||||
|
outputFile<<"\t"<<totalP;
|
||||||
|
outputFile<<"\t"<<men.size();
|
||||||
|
outputFile<<"\t"<<women.size();
|
||||||
|
|
||||||
|
int totalDeaf = 0;
|
||||||
|
for(auto i = 0; i < men.size(); i++){
|
||||||
|
if(men.at(i)->deaf())
|
||||||
|
totalDeaf++;
|
||||||
|
}
|
||||||
|
for(auto i = 0; i < women.size(); i++){
|
||||||
|
if(women.at(i)->deaf())
|
||||||
|
totalDeaf++;
|
||||||
|
}
|
||||||
|
outputFile<<"\t"<<totalDeaf;
|
||||||
|
|
||||||
|
int sumMarriages = marriageDD + marriageDH + marriageHH;
|
||||||
|
int sumChildren = newMen.size() + newWomen.size();
|
||||||
|
outputFile<<"\t"<<float(marriageDD)/sumMarriages;
|
||||||
|
outputFile<<"\t"<<float(childrenDD)/sumChildren;
|
||||||
|
outputFile<<"\t"<<float(marriageDH)/sumMarriages;
|
||||||
|
outputFile<<"\t"<<float(childrenDH)/sumChildren;
|
||||||
|
outputFile<<"\t"<<float(marriageHH)/sumMarriages;
|
||||||
|
outputFile<<"\t"<<float(childrenHH)/sumChildren;
|
||||||
|
|
||||||
|
int deafAllelesTotal = 0;
|
||||||
|
int deafHomoz = 0;
|
||||||
|
for(unsigned int i = 0; i< men.size(); i++){
|
||||||
|
int deafAlleles = men.at(i)->getDeafAllelesCount();
|
||||||
|
deafAllelesTotal += deafAlleles;
|
||||||
|
//int increase = deafAllelesTotal == 2 ? 1 : 0;
|
||||||
|
deafHomoz += deafAlleles/2;
|
||||||
|
}
|
||||||
|
for(unsigned int i = 0; i< women.size(); i++){
|
||||||
|
int deafAlleles = women.at(i)->getDeafAllelesCount();
|
||||||
|
deafAllelesTotal += deafAlleles;
|
||||||
|
//int increase = deafAllelesTotal == 2 ? 1 : 0;
|
||||||
|
deafHomoz += deafAlleles/2;
|
||||||
|
}
|
||||||
|
|
||||||
|
outputFile<<"\t"<<float(deafAllelesTotal)/(2*totalP);
|
||||||
|
outputFile<<"\t"<<float(deafHomoz)/totalP;
|
||||||
|
/*
|
||||||
|
outputFile<<"\tDA frequency\tDA homozygotes frequency";
|
||||||
|
*/
|
||||||
|
outputFile<<"\n";
|
||||||
|
|
||||||
|
std::cout<<"Done\n";
|
||||||
|
|
||||||
|
std::cout<<"\tDeleting old agents\t";
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
for(int i = 0; i < men.size(); i++){
|
||||||
|
delete men.at(i);
|
||||||
|
}
|
||||||
|
for(int i = 0; i < women.size(); i++){
|
||||||
|
delete women.at(i);
|
||||||
|
}
|
||||||
|
std::cout<<"Done\n";
|
||||||
|
|
||||||
|
std::cout<<"\tReplacing old by new and shuffling\t";
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
men = newMen;
|
||||||
|
women = newWomen;
|
||||||
|
std::random_shuffle(men.begin(), men.end());
|
||||||
|
std::random_shuffle(women.begin(), women.end());
|
||||||
|
|
||||||
|
std::cout<<"Done\n";
|
||||||
|
std::cout<<"\tClearing\t";
|
||||||
|
newMen.clear();
|
||||||
|
newWomen.clear();
|
||||||
|
std::cout<<"Done\n";
|
||||||
|
|
||||||
|
} // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||||
|
outputFile.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
float Processor::esteem(Agent* man, Agent* woman){
|
||||||
|
float ans = 0.0f;
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
if( (man->getFatherID() == woman->getFatherID() ||
|
||||||
|
man->getMotherID() == woman->getMotherID()) && woman->getMotherID() != -1){
|
||||||
|
return -50.f;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(man->deaf() == woman->deaf()){
|
||||||
|
if(man->deaf()){
|
||||||
|
ans += 2*Settings::WEIGHT_PHENO_D;
|
||||||
|
float sum1 = man->knowsSign() ? Settings::WEIGHT_SIGN_D : 0;
|
||||||
|
float sum2 = woman->knowsSign() ? Settings::WEIGHT_SIGN_D : 0;
|
||||||
|
ans += sum1+sum2;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
ans += 2*Settings::WEIGHT_PHENO_H;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(man->knowsSign() && woman->knowsSign()){
|
||||||
|
ans += Settings::WEIGHT_SIGN_D + Settings::WEIGHT_SIGN_H;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(man->getSocialP() + woman->getSocialP() > ans)
|
||||||
|
return 0.0f;
|
||||||
|
|
||||||
|
return ans;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Processor::initSettings(std::string fileName){
|
||||||
|
std::vector<std::string> script;
|
||||||
|
std::ifstream file(fileName.c_str());
|
||||||
|
std::string str;
|
||||||
|
|
||||||
|
while(getline(file,str)){
|
||||||
|
if(str.length() > 2)
|
||||||
|
script.push_back(str);
|
||||||
|
}
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
// process Script
|
||||||
|
unsigned int curLine;
|
||||||
|
for(curLine = 0; curLine < script.size(); curLine++){
|
||||||
|
if(script.at(curLine).at(0) == '/' || script.at(curLine).at(0) == '#')
|
||||||
|
continue;
|
||||||
|
|
||||||
|
std::vector<std::string > tokensVector; // Search for tokens
|
||||||
|
//boost::split(tokensVector, script.at(curLine), boost::is_any_of("=") );
|
||||||
|
boost::split(tokensVector, script.at(curLine), std::bind2nd(std::equal_to<char>(), '='));
|
||||||
|
|
||||||
|
std::string instr = tokensVector.at(0);
|
||||||
|
boost::to_lower(instr);
|
||||||
|
boost::trim(instr);
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
if(instr == "generations" || instr == "iterations" ){
|
||||||
|
int iter = Settings::MAX_GENERATIONS;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%d", &iter);
|
||||||
|
Settings::MAX_GENERATIONS = iter;
|
||||||
|
}
|
||||||
|
if(instr == "init_pop_men"){
|
||||||
|
int pop = Settings::INIT_POP_SIZE_M;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%d", &pop);
|
||||||
|
Settings::INIT_POP_SIZE_M = pop;
|
||||||
|
}
|
||||||
|
if(instr == "init_pop_women"){
|
||||||
|
int pop = Settings::INIT_POP_SIZE_W;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%d", &pop);
|
||||||
|
Settings::INIT_POP_SIZE_W = pop;
|
||||||
|
}
|
||||||
|
if(instr == "candidate_pairs_mean"){
|
||||||
|
int cand = Settings::CANDIDATE_PAIRS_MEAN;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%d", &cand);
|
||||||
|
Settings::CANDIDATE_PAIRS_MEAN = cand;
|
||||||
|
}
|
||||||
|
if(instr == "candidate_pairs_var"){
|
||||||
|
int cand = Settings::CANDIDATE_PAIRS_VAR;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%d", &cand);
|
||||||
|
Settings::CANDIDATE_PAIRS_VAR = cand;
|
||||||
|
}
|
||||||
|
else if(instr == "spontaneous_deaf"){
|
||||||
|
float deaf = Settings::SPONTANEOUS_DEAF;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%f", &deaf);
|
||||||
|
Settings::SPONTANEOUS_DEAF = deaf;
|
||||||
|
}
|
||||||
|
else if(instr == "deaf_allele_ratio"){
|
||||||
|
float deaf = Settings::DEAF_ALLELE_RATIO;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%f", &deaf);
|
||||||
|
Settings::DEAF_ALLELE_RATIO = deaf;
|
||||||
|
}
|
||||||
|
else if(instr == "deaf_homozygotes"){
|
||||||
|
float deaf = Settings::DEAF_HOMOZYGOTES;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%f", &deaf);
|
||||||
|
Settings::DEAF_HOMOZYGOTES = deaf;
|
||||||
|
}
|
||||||
|
else if(instr == "hear_homozygotes"){
|
||||||
|
float hear = Settings::HEAR_HOMOZYGOTES;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%f", &hear);
|
||||||
|
Settings::HEAR_HOMOZYGOTES = hear;
|
||||||
|
}
|
||||||
|
else if(instr == "birth_rate_hearing" || instr == "birth_rate_h"){
|
||||||
|
float rate = Settings::BIRTH_RATE_H;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%f", &rate);
|
||||||
|
Settings::BIRTH_RATE_H = rate;
|
||||||
|
}
|
||||||
|
else if(instr == "birth_rate_deaf" || instr == "birth_rate_d"){
|
||||||
|
float rate = Settings::BIRTH_RATE_D;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%f", &rate);
|
||||||
|
Settings::BIRTH_RATE_D = rate;
|
||||||
|
}
|
||||||
|
else if(instr == "beta_a"){
|
||||||
|
float rate = Settings::BETA_A;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%f", &rate);
|
||||||
|
Settings::BETA_A = rate;
|
||||||
|
}
|
||||||
|
else if(instr == "beta_b"){
|
||||||
|
float rate = Settings::BETA_B;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%f", &rate);
|
||||||
|
Settings::BETA_B = rate;
|
||||||
|
}
|
||||||
|
else if(instr == "social_mean_h" || instr == "social_mean_hearing"){
|
||||||
|
float rate = Settings::SOCIAL_MEAN_H;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%f", &rate);
|
||||||
|
Settings::SOCIAL_MEAN_H = rate;
|
||||||
|
}
|
||||||
|
else if(instr == "social_mean_d" || instr == "social_mean_deaf"){
|
||||||
|
float rate = Settings::SOCIAL_MEAN_D;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%f", &rate);
|
||||||
|
Settings::SOCIAL_MEAN_D = rate;
|
||||||
|
}
|
||||||
|
else if(instr == "social_var_h" || instr == "social_var_hearing"){
|
||||||
|
float rate = Settings::SOCIAL_VAR_H;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%f", &rate);
|
||||||
|
Settings::SOCIAL_VAR_H = rate;
|
||||||
|
}
|
||||||
|
else if(instr == "social_var_d" || instr == "social_var_deaf"){
|
||||||
|
float rate = Settings::SOCIAL_VAR_D;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%f", &rate);
|
||||||
|
Settings::SOCIAL_VAR_D = rate;
|
||||||
|
}
|
||||||
|
else if(instr == "weight_phenotype_hearing" || instr == "weight_pheno_h"){
|
||||||
|
float rate = Settings::WEIGHT_PHENO_H;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%f", &rate);
|
||||||
|
Settings::WEIGHT_PHENO_H = rate;
|
||||||
|
}
|
||||||
|
else if(instr == "weight_phenotype_deaf" || instr == "weight_pheno_d"){
|
||||||
|
float rate = Settings::WEIGHT_PHENO_D;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%f", &rate);
|
||||||
|
Settings::WEIGHT_PHENO_D = rate;
|
||||||
|
}
|
||||||
|
else if(instr == "weight_sign_h" || instr == "weight_sign_hearing"){
|
||||||
|
float rate = Settings::WEIGHT_SIGN_H;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%f", &rate);
|
||||||
|
Settings::WEIGHT_SIGN_H = rate;
|
||||||
|
}
|
||||||
|
else if(instr == "weight_sign_d" || instr == "weight_sign_deaf"){
|
||||||
|
float rate = Settings::WEIGHT_SIGN_D;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%f", &rate);
|
||||||
|
Settings::WEIGHT_SIGN_D = rate;
|
||||||
|
}
|
||||||
|
else if(instr == "sign_lang_d" || instr == "sign_lang_deaf"){
|
||||||
|
float rate = Settings::SIGN_LANG_DEAF;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%f", &rate);
|
||||||
|
Settings::SIGN_LANG_DEAF = rate;
|
||||||
|
}
|
||||||
|
else if(instr == "sign_lang_h" || instr == "sign_lang_hear"){
|
||||||
|
float rate = Settings::SIGN_LANG_HEAR;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%f", &rate);
|
||||||
|
Settings::SIGN_LANG_HEAR = rate;
|
||||||
|
}
|
||||||
|
else if(instr == "output" || instr == "output_file"){
|
||||||
|
std::string file = tokensVector.at(1);
|
||||||
|
boost::trim(file);
|
||||||
|
Settings::OUTPUT_FILE = file;
|
||||||
|
}
|
||||||
|
/*if(instr == "fullstat"){
|
||||||
|
int flag = 0;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%d", &flag);
|
||||||
|
if(flag != 0)
|
||||||
|
Settings::WRITE_FULL_STATISTICS_TO_FILE = true;
|
||||||
|
}*/
|
||||||
|
/*else if(instr == "birth" || instr == "birthrate" || instr == "birth_rate" ){
|
||||||
|
double rate = Settings::BirthRate;
|
||||||
|
sscanf_s(tokensVector.at(1).c_str(),"%lg", &rate);
|
||||||
|
Settings::BirthRate = rate;
|
||||||
|
}*/
|
||||||
|
} // (END) for(curLine = 0; curLine < script.size(); curLine++)
|
||||||
|
|
||||||
|
}
|
||||||
32
script1.txt
Normal file
32
script1.txt
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Deaf2.0
|
||||||
|
|
||||||
|
generations = 20
|
||||||
|
|
||||||
|
init_pop_men = 1000000
|
||||||
|
init_pop_women = 1000000
|
||||||
|
|
||||||
|
spontaneous_deaf = 0.0012
|
||||||
|
MAX_GENERATIONS = 20
|
||||||
|
|
||||||
|
CANDIDATE_PAIRS_MEAN = 100
|
||||||
|
CANDIDATE_PAIRS_VAR = 30
|
||||||
|
|
||||||
|
SPONTANEOUS_DEAF = 0.001f
|
||||||
|
DEAF_ALLELE_RATIO = 0.1f
|
||||||
|
DEAF_HOMOZYGOTES = 0.25f
|
||||||
|
|
||||||
|
BIRTH_RATE_H = 2.05f
|
||||||
|
BIRTH_RATE_D = 2.05f
|
||||||
|
|
||||||
|
BETA_A = 2.0f
|
||||||
|
BETA_B = 5.0f
|
||||||
|
|
||||||
|
SOCIAL_MEAN_H = 0.3f
|
||||||
|
SOCIAL_VAR_H = 0.05f
|
||||||
|
SOCIAL_MEAN_D = 0.3f
|
||||||
|
SOCIAL_VAR_D = 0.05f
|
||||||
|
|
||||||
|
WEIGHT_PHENO_H = 0.7f
|
||||||
|
WEIGHT_SIGN_H = 0.3f
|
||||||
|
WEIGHT_PHENO_D = 0.58f
|
||||||
|
WEIGHT_SIGN_D = 0.42f
|
||||||
BIN
Блок схема для Deafness model (Ген, фен, яз_жест).pdf
Normal file
BIN
Блок схема для Deafness model (Ген, фен, яз_жест).pdf
Normal file
Binary file not shown.
Reference in New Issue
Block a user