1
0
forked from s444399/AI

kompletny algorytm genetyczny bez rozwozenia boxow i interface

This commit is contained in:
tomasz 2020-05-18 12:53:51 +02:00
parent d25c4213de
commit ac04e30a96
13 changed files with 324 additions and 163 deletions

View File

@ -2,12 +2,12 @@
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="8264ee8d-5217-4cb6-b982-78f67fabc82e" name="Default Changelist" comment=""> <list default="true" id="8264ee8d-5217-4cb6-b982-78f67fabc82e" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/genetyczny/Gene.py" afterDir="false" /> <change afterPath="$PROJECT_DIR$/genetyczny/genetyczny.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/AStar.py" beforeDir="false" afterPath="$PROJECT_DIR$/AStar.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Mapa/generate.py" beforeDir="false" afterPath="$PROJECT_DIR$/Mapa/generate.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/genetyczny/Data.py" beforeDir="false" afterPath="$PROJECT_DIR$/genetyczny/Data.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/genetyczny/Data.py" beforeDir="false" afterPath="$PROJECT_DIR$/genetyczny/Data.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/genetyczny/randomBox.py" beforeDir="false" afterPath="$PROJECT_DIR$/genetyczny/funkcje.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/genetyczny/Gene.py" beforeDir="false" afterPath="$PROJECT_DIR$/genetyczny/Gene.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/genetyczny/funkcje.py" beforeDir="false" afterPath="$PROJECT_DIR$/genetyczny/funkcje.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/program.py" beforeDir="false" afterPath="$PROJECT_DIR$/program.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/program.py" beforeDir="false" afterPath="$PROJECT_DIR$/program.py" afterDir="false" />
</list> </list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
@ -24,8 +24,8 @@
<file pinned="false" current-in-tab="false"> <file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/program.py"> <entry file="file://$PROJECT_DIR$/program.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="725"> <state relative-caret-position="829">
<caret line="98" selection-start-line="98" selection-end-line="98" /> <caret line="103" column="72" selection-start-line="103" selection-start-column="72" selection-end-line="103" selection-end-column="72" />
<folding> <folding>
<element signature="e#0#13#0" expanded="true" /> <element signature="e#0#13#0" expanded="true" />
</folding> </folding>
@ -33,11 +33,20 @@
</provider> </provider>
</entry> </entry>
</file> </file>
<file pinned="false" current-in-tab="true"> <file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/AStarState.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="153">
<caret line="9" selection-start-line="9" selection-end-line="9" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/genetyczny/Gene.py"> <entry file="file://$PROJECT_DIR$/genetyczny/Gene.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="136"> <state relative-caret-position="102">
<caret line="8" lean-forward="true" selection-start-line="8" selection-end-line="8" /> <caret line="6" column="16" selection-start-line="6" selection-start-column="16" selection-end-line="6" selection-end-column="16" />
</state> </state>
</provider> </provider>
</entry> </entry>
@ -46,7 +55,7 @@
<entry file="file://$PROJECT_DIR$/Mapa/box.py"> <entry file="file://$PROJECT_DIR$/Mapa/box.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="68"> <state relative-caret-position="68">
<caret line="4" column="24" lean-forward="true" selection-start-line="4" selection-start-column="24" selection-end-line="4" selection-end-column="24" /> <caret line="4" column="24" selection-start-line="4" selection-start-column="24" selection-end-line="4" selection-end-column="24" />
</state> </state>
</provider> </provider>
</entry> </entry>
@ -54,8 +63,8 @@
<file pinned="false" current-in-tab="false"> <file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/main.py"> <entry file="file://$PROJECT_DIR$/main.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="612"> <state relative-caret-position="595">
<caret line="36" column="24" selection-start-line="36" selection-start-column="24" selection-end-line="36" selection-end-column="24" /> <caret line="35" column="26" selection-start-line="35" selection-start-column="26" selection-end-line="35" selection-end-column="26" />
<folding> <folding>
<element signature="e#0#21#0" expanded="true" /> <element signature="e#0#21#0" expanded="true" />
</folding> </folding>
@ -66,8 +75,8 @@
<file pinned="false" current-in-tab="false"> <file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/AStar.py"> <entry file="file://$PROJECT_DIR$/AStar.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="442"> <state relative-caret-position="357">
<caret line="35" selection-start-line="35" selection-end-line="35" /> <caret line="21" selection-start-line="21" selection-end-line="21" />
<folding> <folding>
<element signature="e#0#12#0" expanded="true" /> <element signature="e#0#12#0" expanded="true" />
</folding> </folding>
@ -78,8 +87,8 @@
<file pinned="false" current-in-tab="false"> <file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/genetyczny/funkcje.py"> <entry file="file://$PROJECT_DIR$/genetyczny/funkcje.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state> <state relative-caret-position="339">
<caret line="21" column="23" selection-start-line="21" selection-start-column="15" selection-end-line="21" selection-end-column="23" /> <caret line="145" selection-start-line="145" selection-end-line="145" />
<folding> <folding>
<element signature="e#0#48#0" expanded="true" /> <element signature="e#0#48#0" expanded="true" />
</folding> </folding>
@ -87,11 +96,11 @@
</provider> </provider>
</entry> </entry>
</file> </file>
<file pinned="false" current-in-tab="false"> <file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/Mapa/shelf.py"> <entry file="file://$PROJECT_DIR$/genetyczny/genetyczny.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="34"> <state relative-caret-position="17">
<caret line="2" column="11" selection-start-line="2" selection-start-column="6" selection-end-line="2" selection-end-column="11" /> <caret line="1" lean-forward="true" selection-start-line="1" selection-end-line="1" />
</state> </state>
</provider> </provider>
</entry> </entry>
@ -99,8 +108,8 @@
<file pinned="false" current-in-tab="false"> <file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/genetyczny/Data.py"> <entry file="file://$PROJECT_DIR$/genetyczny/Data.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="102"> <state relative-caret-position="238">
<caret line="6" column="25" selection-start-line="6" selection-start-column="13" selection-end-line="6" selection-end-column="25" /> <caret line="14" column="27" selection-start-line="14" selection-start-column="27" selection-end-line="14" selection-end-column="27" />
</state> </state>
</provider> </provider>
</entry> </entry>
@ -116,10 +125,6 @@
</component> </component>
<component name="FindInProjectRecents"> <component name="FindInProjectRecents">
<findStrings> <findStrings>
<find>toVisit</find>
<find>dra</find>
<find>neuro</find>
<find>where</find>
<find>regals</find> <find>regals</find>
<find>isOccupied</find> <find>isOccupied</find>
<find>print</find> <find>print</find>
@ -146,13 +151,17 @@
<find>mapfor</find> <find>mapfor</find>
<find>tmp</find> <find>tmp</find>
<find>global</find> <find>global</find>
<find>cop</find>
<find>jakLiczycKoszt</find>
<find>jakLiczyc</find>
<find>fitness</find>
</findStrings> </findStrings>
</component> </component>
<component name="Git.Settings"> <component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
<option name="RECENT_BRANCH_BY_REPOSITORY"> <option name="RECENT_BRANCH_BY_REPOSITORY">
<map> <map>
<entry key="$PROJECT_DIR$" value="podprogram" /> <entry key="$PROJECT_DIR$" value="randomBox" />
</map> </map>
</option> </option>
</component> </component>
@ -171,20 +180,21 @@
<option value="$PROJECT_DIR$/genetyczny/randomBox.py" /> <option value="$PROJECT_DIR$/genetyczny/randomBox.py" />
<option value="$PROJECT_DIR$/Mapa/generate.py" /> <option value="$PROJECT_DIR$/Mapa/generate.py" />
<option value="$PROJECT_DIR$/AStar.py" /> <option value="$PROJECT_DIR$/AStar.py" />
<option value="$PROJECT_DIR$/genetyczny/Data.py" />
<option value="$PROJECT_DIR$/main.py" />
<option value="$PROJECT_DIR$/genetyczny/funkcje.py" />
<option value="$PROJECT_DIR$/program.py" />
<option value="$PROJECT_DIR$/genetyczny/Gene1.py" /> <option value="$PROJECT_DIR$/genetyczny/Gene1.py" />
<option value="$PROJECT_DIR$/genetyczny/Gene.py" /> <option value="$PROJECT_DIR$/genetyczny/Gene.py" />
<option value="$PROJECT_DIR$/genetyczny/funkcje.py" />
<option value="$PROJECT_DIR$/genetyczny/Data.py" />
<option value="$PROJECT_DIR$/program.py" />
<option value="$PROJECT_DIR$/main.py" />
<option value="$PROJECT_DIR$/genetyczny/genetyczny.py" />
</list> </list>
</option> </option>
</component> </component>
<component name="ProjectFrameBounds" extendedState="7"> <component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="-9" /> <option name="x" value="1897" />
<option name="y" value="-9" /> <option name="y" value="-9" />
<option name="width" value="1938" /> <option name="width" value="1551" />
<option name="height" value="1098" /> <option name="height" value="879" />
</component> </component>
<component name="ProjectLevelVcsManager" settingsEditedManually="true" /> <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectView"> <component name="ProjectView">
@ -239,7 +249,7 @@
</option> </option>
</component> </component>
<component name="RunManager" selected="Python.main"> <component name="RunManager" selected="Python.main">
<configuration name="AStar" type="PythonConfigurationType" factoryName="Python" temporary="true"> <configuration name="funkcje" type="PythonConfigurationType" factoryName="Python" temporary="true">
<module name="AI" /> <module name="AI" />
<option name="INTERPRETER_OPTIONS" value="" /> <option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" /> <option name="PARENT_ENVS" value="true" />
@ -247,32 +257,11 @@
<env name="PYTHONUNBUFFERED" value="1" /> <env name="PYTHONUNBUFFERED" value="1" />
</envs> </envs>
<option name="SDK_HOME" value="" /> <option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" /> <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/genetyczny" />
<option name="IS_MODULE_SDK" value="true" /> <option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/AStar.py" /> <option name="SCRIPT_NAME" value="$PROJECT_DIR$/genetyczny/funkcje.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="generate" type="PythonConfigurationType" factoryName="Python" temporary="true">
<module name="AI" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="C:\Users\zwyklak\Desktop\AI\Mapa\generate.py" />
<option name="PARAMETERS" value="" /> <option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" /> <option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" /> <option name="EMULATE_TERMINAL" value="false" />
@ -344,13 +333,34 @@
<option name="INPUT_FILE" value="" /> <option name="INPUT_FILE" value="" />
<method v="2" /> <method v="2" />
</configuration> </configuration>
<configuration name="program" type="PythonConfigurationType" factoryName="Python" temporary="true">
<module name="AI" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/program.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<recent_temporary> <recent_temporary>
<list> <list>
<item itemvalue="Python.main" /> <item itemvalue="Python.main" />
<item itemvalue="Python.program" />
<item itemvalue="Python.funkcje" />
<item itemvalue="Python.neurons" /> <item itemvalue="Python.neurons" />
<item itemvalue="Python.julian" /> <item itemvalue="Python.julian" />
<item itemvalue="Python.generate" />
<item itemvalue="Python.AStar" />
</list> </list>
</recent_temporary> </recent_temporary>
</component> </component>
@ -380,23 +390,23 @@
</todo-panel> </todo-panel>
</component> </component>
<component name="ToolWindowManager"> <component name="ToolWindowManager">
<frame x="-7" y="-7" width="1550" height="838" extended-state="7" /> <frame x="1912" y="-8" width="1216" height="1576" extended-state="6" />
<editor active="true" /> <editor active="true" />
<layout> <layout>
<window_info active="true" content_ui="combo" id="Project" order="0" sideWeight="0.4995206" visible="true" weight="0.20671141" /> <window_info active="true" content_ui="combo" id="Project" order="0" sideWeight="0.4995206" visible="true" weight="0.2733564" />
<window_info id="Structure" order="1" sideWeight="0.5004794" side_tool="true" weight="0.3382353" /> <window_info id="Structure" order="1" sideWeight="0.5004794" side_tool="true" weight="0.3382353" />
<window_info id="Favorites" order="2" sideWeight="0.5011338" side_tool="true" weight="0.27768165" /> <window_info id="Favorites" order="2" sideWeight="0.5011338" side_tool="true" weight="0.27768165" />
<window_info anchor="bottom" id="Message" order="0" /> <window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" weight="0.32719547" /> <window_info anchor="bottom" id="Find" order="1" weight="0.3270963" />
<window_info anchor="bottom" id="Run" order="2" sideWeight="0.49932885" visible="true" weight="0.22096318" /> <window_info anchor="bottom" id="Run" order="2" sideWeight="0.49932885" weight="0.22037423" />
<window_info anchor="bottom" id="Cvs" order="3" weight="0.25" /> <window_info anchor="bottom" id="Cvs" order="3" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="4" weight="0.4" /> <window_info anchor="bottom" id="Inspection" order="4" weight="0.4" />
<window_info anchor="bottom" x="1942" y="641" width="1156" height="277" id="Debug" order="5" sideWeight="0.49932885" weight="0.27443105" /> <window_info anchor="bottom" x="1942" y="641" width="1156" height="277" id="Debug" order="5" sideWeight="0.49932885" visible="true" weight="0.13305613" />
<window_info anchor="bottom" id="TODO" order="6" weight="0.32848233" /> <window_info anchor="bottom" id="TODO" order="6" weight="0.32848233" />
<window_info anchor="bottom" id="Version Control" order="7" weight="0.32848233" /> <window_info anchor="bottom" id="Version Control" order="7" weight="0.32848233" />
<window_info anchor="bottom" id="Terminal" order="8" weight="0.3286119" /> <window_info anchor="bottom" id="Terminal" order="8" weight="0.32848233" />
<window_info anchor="bottom" id="Event Log" order="9" sideWeight="0.50067115" side_tool="true" weight="0.3753541" /> <window_info anchor="bottom" id="Event Log" order="9" sideWeight="0.50067115" side_tool="true" weight="0.3753541" />
<window_info anchor="bottom" id="Python Console" order="10" /> <window_info anchor="bottom" id="Python Console" order="10" weight="0.32986832" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" /> <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" /> <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" /> <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
@ -429,9 +439,9 @@
<breakpoint-manager> <breakpoint-manager>
<breakpoints> <breakpoints>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line"> <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/program.py</url> <url>file://$PROJECT_DIR$/genetyczny/funkcje.py</url>
<line>98</line> <line>145</line>
<option name="timeStamp" value="131" /> <option name="timeStamp" value="171" />
</line-breakpoint> </line-breakpoint>
</breakpoints> </breakpoints>
<default-breakpoints> <default-breakpoints>
@ -533,13 +543,6 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python37/Lib/random.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="138">
<caret line="260" selection-start-line="260" selection-end-line="260" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/neurons.py"> <entry file="file://$PROJECT_DIR$/neurons.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="595"> <state relative-caret-position="595">
@ -567,6 +570,58 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/Mapa/shelf.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="34">
<caret line="2" column="11" selection-start-line="2" selection-start-column="6" selection-end-line="2" selection-end-column="11" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/Mapa/box.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="68">
<caret line="4" column="24" selection-start-line="4" selection-start-column="24" selection-end-line="4" selection-end-column="24" />
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/AppData/Local/Programs/Python/Python37/Lib/random.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="366">
<caret line="194" selection-start-line="194" selection-end-line="194" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/genetyczny/Data.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="238">
<caret line="14" column="27" selection-start-line="14" selection-start-column="27" selection-end-line="14" selection-end-column="27" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/genetyczny/Gene.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="102">
<caret line="6" column="16" selection-start-line="6" selection-start-column="16" selection-end-line="6" selection-end-column="16" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/Mapa/generate.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="801">
<caret line="163" column="21" selection-start-line="163" selection-start-column="21" selection-end-line="163" selection-end-column="21" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/main.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="595">
<caret line="35" column="26" selection-start-line="35" selection-start-column="26" selection-end-line="35" selection-end-column="26" />
<folding>
<element signature="e#0#21#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/AStarState.py"> <entry file="file://$PROJECT_DIR$/AStarState.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="153"> <state relative-caret-position="153">
@ -576,76 +631,38 @@
</entry> </entry>
<entry file="file://$PROJECT_DIR$/AStar.py"> <entry file="file://$PROJECT_DIR$/AStar.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="442"> <state relative-caret-position="357">
<caret line="35" selection-start-line="35" selection-end-line="35" /> <caret line="21" selection-start-line="21" selection-end-line="21" />
<folding> <folding>
<element signature="e#0#12#0" expanded="true" /> <element signature="e#0#12#0" expanded="true" />
</folding> </folding>
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/Mapa/generate.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="952">
<caret line="174" selection-start-line="174" selection-end-line="174" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/main.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="612">
<caret line="36" column="24" selection-start-line="36" selection-start-column="24" selection-end-line="36" selection-end-column="24" />
<folding>
<element signature="e#0#21#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/Mapa/box.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="68">
<caret line="4" column="24" lean-forward="true" selection-start-line="4" selection-start-column="24" selection-end-line="4" selection-end-column="24" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/genetyczny/Data.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="102">
<caret line="6" column="25" selection-start-line="6" selection-start-column="13" selection-end-line="6" selection-end-column="25" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/program.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="725">
<caret line="98" selection-start-line="98" selection-end-line="98" />
<folding>
<element signature="e#0#13#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/genetyczny/funkcje.py"> <entry file="file://$PROJECT_DIR$/genetyczny/funkcje.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state> <state relative-caret-position="339">
<caret line="21" column="23" selection-start-line="21" selection-start-column="15" selection-end-line="21" selection-end-column="23" /> <caret line="145" selection-start-line="145" selection-end-line="145" />
<folding> <folding>
<element signature="e#0#48#0" expanded="true" /> <element signature="e#0#48#0" expanded="true" />
</folding> </folding>
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/Mapa/shelf.py"> <entry file="file://$PROJECT_DIR$/program.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="34"> <state relative-caret-position="829">
<caret line="2" column="11" selection-start-line="2" selection-start-column="6" selection-end-line="2" selection-end-column="11" /> <caret line="103" column="72" selection-start-line="103" selection-start-column="72" selection-end-line="103" selection-end-column="72" />
<folding>
<element signature="e#0#13#0" expanded="true" />
</folding>
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/genetyczny/Gene.py"> <entry file="file://$PROJECT_DIR$/genetyczny/genetyczny.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="136"> <state relative-caret-position="17">
<caret line="8" lean-forward="true" selection-start-line="8" selection-end-line="8" /> <caret line="1" lean-forward="true" selection-start-line="1" selection-end-line="1" />
</state> </state>
</provider> </provider>
</entry> </entry>

Binary file not shown.

Binary file not shown.

View File

@ -8,7 +8,11 @@ class Data:
self.mapa = [] self.mapa = []
self.unbox = [] self.unbox = []
self.astarMap = [] self.astarMap = []
self.geny = []
self.kordyWozka = None
self.jakLiczycKoszt = None
self.best = None
self.histZmian = []
def genMap(self, mapa): def genMap(self, mapa):
tmpMap =[] tmpMap =[]

View File

@ -1,8 +1,8 @@
class Gene: class Gene:
def __init__(self, poczatkowa, koncowa, name): def __init__(self, kordydnaty):
self.poczatkowa = poczatkowa self.kordy = kordydnaty
self.koncowa = koncowa self.unbox1 = None
self.koszt = 0 self.unbox2 = None
self.name = name self.ktoryUnbox = None

Binary file not shown.

View File

@ -3,6 +3,20 @@ from genetyczny.Gene import Gene
from Mapa.box import Box from Mapa.box import Box
from AStar import AStar from AStar import AStar
import random import random
import numpy
def generateGeny(data):
zajeteRegaly = data.zajeteRegaly[:]
for r in zajeteRegaly:
g = Gene(r)
g.unbox1 = policzCost(data.astarMap,r,data.unbox[0])
if(len(data.unbox) > 1):
g.unbox2 = policzCost(data.astarMap,r,data.unbox[1])
data.geny.append(g)
def znajdzUnbox(data,mapa): def znajdzUnbox(data,mapa):
@ -15,8 +29,7 @@ def znajdzUnbox(data,mapa):
iterator += 1 iterator += 1
data.unbox = unboxy data.unbox = unboxy
def wybierzUnbox(data):
return random.choice(data.unbox)
def policzCost(mapaBoxy, poczatek, koniec): def policzCost(mapaBoxy, poczatek, koniec):
@ -24,31 +37,69 @@ def policzCost(mapaBoxy, poczatek, koniec):
koszt = astar.search(poczatek, koniec, mapaBoxy, 1, 0) koszt = astar.search(poczatek, koniec, mapaBoxy, 1, 0)
return koszt return koszt
def generateChromosome(data, mapaBoxy, wheelxy): def genRandomChromosome(data):
chromosome = [] chromosome = data.geny[:]
regaly = data.zajeteRegaly random.shuffle(chromosome)
random.shuffle(regaly) krotkaKosztJakiUnbox = None
unboxLastGen = None
for r in regaly:
gen0 = Gene(wheelxy,r,"poczatek-regal")
gen0.koszt = policzCost(mapaBoxy, wheelxy, r)
chromosome.append(gen0)
unbox = wybierzUnbox(data)
gen1 = Gene(r,unbox,"regal-unbox")
gen1.koszt = policzCost(mapaBoxy, r, unbox)
chromosome.append(gen1)
for gen in chromosome:
gen.ktoryUnbox = unboxLastGen
krotkaKosztJakiUnbox = wybierzUnbox(gen, data.jakLiczycKoszt)
unboxLastGen = krotkaKosztJakiUnbox[1]
return chromosome return chromosome
def generatePopulation(data, mapaBoxy, wheelxy, ileWPopulacji): def genRandomPopulation(data, ileWPopulacji):
populacja = [] populacja = []
for i in range(ileWPopulacji): for i in range(ileWPopulacji):
populacja.append(generateChromosome(data, mapaBoxy, wheelxy)) populacja.append(genRandomChromosome(data))
return populacja return populacja
def fitness(chromosome, data):
koszt = 0
unboxPoprzedniegoGenu = None
for item, gen in enumerate(chromosome):
if(item == 0):
koszt += policzCost(data.astarMap, data.kordyWozka, gen.kordy)
krotkaKosztJakiUnbox = wybierzUnbox(gen, data.jakLiczycKoszt)
koszt += krotkaKosztJakiUnbox[0]
unboxPoprzedniegoGenu = krotkaKosztJakiUnbox[1]
else:
if unboxPoprzedniegoGenu == 0:
koszt += gen.unbox1
elif unboxPoprzedniegoGenu == 1:
koszt += gen.unbox2
krotkaKosztJakiUnbox = wybierzUnbox(gen, data.jakLiczycKoszt)
koszt += krotkaKosztJakiUnbox[0]
unboxPoprzedniegoGenu = krotkaKosztJakiUnbox[1]
return koszt
def wybierzUnbox(gen, jakLiczycKoszt):
if(jakLiczycKoszt == 0):
x = random.choice([gen.unbox1, gen.unbox2])
if(x == gen.unbox1):
y = 0
else:
y= 1
return (x,y)
elif(jakLiczycKoszt == 1):
return (gen.unbox1,0)
elif(jakLiczycKoszt == 2):
return (gen.unbox2,1)
elif(jakLiczycKoszt == 3):
x = min(gen.unbox1,gen.unbox2)
if(x == gen.unbox1):
y = 0
else:
y = 1
return (x,y)
def randomBox(mapa, regals, ile): def randomBox(mapa, regals, ile):
regals = regals regals = regals
@ -84,3 +135,83 @@ def znajdzBox(mapa, regals):
if(tmp == True): if(tmp == True):
zajeteRegaly.append((x,y)) zajeteRegaly.append((x,y))
return zajeteRegaly return zajeteRegaly
def dwieNajlepsze(populacja, data):
tmpPopulacja = populacja[:]
chromFitness = []
for chrom in populacja:
chromFitness.append(fitness(chrom,data))
bestValue = min(chromFitness)
bestChromIndex = chromFitness.index(bestValue)
pierwsza = tmpPopulacja[bestChromIndex]
if (data.best == None):
data.best = (pierwsza[:],bestValue)
elif(data.best[1] > bestValue):
data.best = (pierwsza[:],bestValue)
tmpPopulacja.pop(bestChromIndex)
chromFitness.pop(bestChromIndex)
bestValue = min(chromFitness)
bestChromIndex = chromFitness.index(bestValue)
druga = tmpPopulacja[bestChromIndex]
tmpPopulacja.pop(bestChromIndex)
chromFitness.pop(bestChromIndex)
return (pierwsza, druga)
def genPopulacje(pierwszy, drugi, ileWPopulacji, fragmentLiczba, wspMutacji):
ileWChrom = len(pierwszy)
fragment = round(fragmentLiczba*ileWChrom)
nowaPopulacja = []
for i in range(ileWPopulacji):
nowaPopulacja.append(crossover(pierwszy,drugi,fragment, wspMutacji))
return nowaPopulacja
def crossover(pierwszy, drugi, fragmentLiczba, wspMutacji):
ileWChrom = len(pierwszy)
tmp = random.randint(0, ileWChrom-fragmentLiczba)
kordyFragment = (tmp,tmp+fragmentLiczba)
nowyChrom = [None] * ileWChrom
iterator = kordyFragment[1]
pomIterator = kordyFragment[1]
nowyChrom[kordyFragment[0]:kordyFragment[1]] = pierwszy[kordyFragment[0]:kordyFragment[1]]
while(None in nowyChrom):
if(iterator > ileWChrom - 1):
iterator = 0
if(pomIterator > ileWChrom - 1):
pomIterator = 0
if(nowyChrom[iterator] == None and drugi[pomIterator] not in nowyChrom):
nowyChrom[iterator] = drugi[pomIterator]
iterator += 1
pomIterator += 1
elif(nowyChrom[iterator] == None and drugi[pomIterator] in nowyChrom):
pomIterator +=1
nowyChrom = mutate(wspMutacji, nowyChrom)
return nowyChrom
def updateMap(data, map, mapForAstar, regals):
data.mapa = map
znajdzUnbox(data, map)
data.zajeteRegaly = znajdzBox(map, regals)
data.astarMap = data.genMap(mapForAstar)
def mutate(wspMutacji, chrom):
ileWChrom = len(chrom)
ileZmian = round(ileWChrom * wspMutacji)
for i in range(ileZmian):
pom = None
pierw = random.randint(0,ileWChrom - 1)
drug = random.randint(0,ileWChrom - 1)
pom = chrom[pierw]
chrom[pierw] = chrom[drug]
chrom[drug] = pom
return chrom

1
genetyczny/genetyczny.py Normal file
View File

@ -0,0 +1 @@

View File

@ -34,7 +34,7 @@ def main():
""" """
if good: if good:
szerokosc = 15#min 6 szerokosc = 15#min 6
wysokosc = 8 #min 7 wysokosc = 10 #min 7
kruche = 1 kruche = 1
latwopalne = 1 latwopalne = 1
radioaktywne = 1 radioaktywne = 1

View File

@ -58,12 +58,9 @@ class MainWindow:
self.map[i][j] = Shelf(self.screen, self.cell, i, j, (self.map[i][j]-3)%4, (self.map[i][j]-3)//4) self.map[i][j] = Shelf(self.screen, self.cell, i, j, (self.map[i][j]-3)%4, (self.map[i][j]-3)//4)
self.mapForAStar[i][j] = 1 self.mapForAStar[i][j] = 1
self.map = randomBox(self.map, self.regals, 10) self.map = randomBox(self.map, self.regals, 25)
self.data.mapa = self.map updateMap(self.data, self.map, self.mapForAStar, self.regals)
znajdzUnbox(self.data,self.map) generateGeny(self.data)
self.data.zajeteRegaly = znajdzBox(self.map, self.regals)
tmp = self.mapForAStar[:]
self.data.astarMap = self.data.genMap(tmp)
################################################# #################################################
@ -95,7 +92,18 @@ class MainWindow:
print("eee") print("eee")
""" """
elif(event.type==pygame.KEYDOWN): elif(event.type==pygame.KEYDOWN):
populacja = generatePopulation(self.data, self.data.astarMap, [self.wheel.ns, self.wheel.we], 100)
self.data.kordyWozka = (self.wheel.ns, self.wheel.we)
self.data.jakLiczycKoszt = 1
randomPopulation = genRandomPopulation(self.data, 5)
for i in range(100):
if i == 0:
best2 = dwieNajlepsze(randomPopulation, self.data)
else:
x = genPopulacje(best2[0], best2[1], 5, 0.2, 0.3)
best2 = dwieNajlepsze(x, self.data)
self.data.histZmian.append(self.data.best[1])
if len(self.moves)==0: if len(self.moves)==0:
self.wheel.move(event, self.map) self.wheel.move(event, self.map)
elif(event.type==pygame.MOUSEBUTTONDOWN): elif(event.type==pygame.MOUSEBUTTONDOWN):