Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into dev
  • Loading branch information
paulkaneelil committed Jan 4, 2019
2 parents c53664d + 7dae39b commit c95807a
Show file tree
Hide file tree
Showing 37 changed files with 705 additions and 207 deletions.
7 changes: 7 additions & 0 deletions GASTOp.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
"""GASTOp.py
This file runs the gastop program
Authors: Amlan Sinha, Cristian Lacey, Daniel Shaw, Paul Kaneelil, Rory Conlin, Susan Redmond
Licensed under GNU GPLv3.
This module implements the GenAlg class.
"""
import matplotlib.pyplot as plt
from gastop import GenAlg, utilities

Expand Down
149 changes: 149 additions & 0 deletions docs/config_file_format.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,153 @@
Config File Formatting and Options
==================================

The config file includes all the input parameters used to instantiate a
GenAlg() object. Certain parameters must be specified by the user, while other
more advanced parameters can be left blank for simplicity and will default to
reasonable values.

The config file is parsed as a nested dictionary. Each dictionary is
indicated by :code:`[dict]`, and nested dictionaries are indicated by nested
squared brackets, :code:`[[nested dict]]`. Each dictionary contains multiple
arguments indicated by :code:`key: value`. If the value is an integer, float,
or string, simply input the value without quotation marks. For instance,
:code:`key: 3`, :code:`key: 3.14`, or :code:`key: pi`. If the value
is a numpy array, input the value as an array in list format, within single
quotes, like :code:`key: '[[3.14 3.14],[3.14 3.14]]'`.

For instance, the config file:

.. code-block:: python
[dict1]
key1: 3
key2: 3.14
[[sub_dict1]]
sub_key1: apples
[[sub_dict2]]
sub_key2: None
[dict2]
key3: '[[3.14 12.8],[6.7 88.9999]]'
would be parsed, forming the dictionary:

.. code-block:: python
{'dict1':
{'key1':3,
'key2':3.14,
'sub_dict1':{'sub_key1':'apples'},
'sub_dict2':{'sub_key2':None}},
'dict2':
{'key3':array([[3.14 12.8],[6.7 88.9999]])}}
Required Parameters
*******************

General
=======
:code:`[general]` contains the following parameters:

:user_spec_nodes: User-specified nodes (nodes with provided loads and displacement boundary conditions) as an nx3 numpy array of floats in the format :code:`'[[x1 y1 z1],[x2 y2 z2],...,[xn yn zn]]'`.

:loads: The forces and moments acting on each user-specified node as an nx6 numpy array of floats in the format :code:`'[[Fx1,Fy1,Fz1,Mx1,My1,Mz1],[Fx2,Fy2,Fz2,Mx2,My2,Mz2],...,[Fxn,Fyn,Fzn,Mxn,Myn,Mzn]]'`.

:fixtures: The translational and rotational displacements for each user-specified node as an nx6 numpy array of integers in the format :code:`'[[transx1,transy1,transz1,rotx1,roty1,rotz1],[transx2,transy2,transz2,rotx2,roty2,rotz2],...,[transxn,transyn,transzn,rotxn,rotyn,rotzn]]'`. Here :code:`transx1` is the translational degree of freedom in the x direction of the first user-specified node, and :code:`rotx1` is the rotational degree of freedom about the x-axis of the first user-specified node. A :code:`1` indicates fixed, while a :code:`0` indicates the node is free to move along or about the corresponding degree of freedom.

:num_rand_nodes: Maximum number of random nodes as an integer.

:num_rand_edges: Maximum number of random edges as an integer.

:properties_path: Path to the properties CSV as a string. For example, :code:`gastop-config/properties.csv`.

:domain: Allowable domain as a 3x2 numpy array of floats in the format :code:`'[[xmin xmax],[ymin ymax],[zmin zmax]]'`.

Fitness Function Parameters
===========================
:code:`[fitness_params]` contains the following parameters:

:equation: Method for calculating fitness as a string. *Options: weighted_sum, sphere, rosenbrock, rastrigin.*
:parameters:
::
goal_fos: 4
critical_nodes '[3]'
w_fos = 10000
w_mass = 1
w_deflection = 100

Evaluator Parameters
====================
:code:`[evaluator_params]` contains the following parameters:

:struct_solver: Method for solving truss as a string.
- *Options: mat_struct_analysis_DSM*
:mass_solver: Method of calculating the mass of a truss as a string.
- Options: mass_basic
:interferences_solver: Method of determining interferences as a string. *Options: blank_test, interference_ray_tracing*
:cost_solver: Method of calculating the cost of a truss as a string. *Options: cost_calc*

Genetic Algorithm Parameters
============================
:code:`[ga_params]` contains the following parameters:

:num_threads: Number of threads.
-Type: int
:pop_size: = 1000
:num_generations: = 30
:num_elite: =
:percent_mutation: =
:percent_crossover: =
:save_frequency: = 5
:save_filename_prefix: = Recorded_States_

Progress Monitor Parameters
===========================
:code:`[monitor_params]` contains the following parameters:

:progress_display: = 1


Advanced Parameters
*******************

explain different headings and options, with references to API docs

Random Generation Parameters
============================
:code:`[random_params]` contains the following parameters:


Crossover Parameters
====================
:code:`[crossover_params]` contains the following parameters:

:node_crossover_method: =
:edge_crossover_method: =
:property_crossover_method: =
[[node_crossover_params]]
[[edge_crossover_params]]
[[property_crossover_params]]

Mutator Parameters
==================
:code:`[mutator_params]` contains the following parameters:

:node_mutator_method: =
:edge_mutator_method: =
:property_mutator_method: =
[[node_mutator_params]]
std =
[[edge_mutator_params]]
proportions =
[[property_mutator_params]]
proportions =

Selector Parameters
===================
:code:`[selector_params]` contains the following parameters:

:method: =
:tourn_size: = 31 # Must be less than 32
:tourn_prob: = 0.5
8 changes: 6 additions & 2 deletions gastop-config/boolean_parse_test_init.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ num_generations = 30
num_elite =
percent_mutation =
percent_crossover =
save_frequency = 5
save_filename_prefix = Recorded_States_

[monitor_params]
progress_display = 1
Expand All @@ -43,6 +45,7 @@ progress_display = 1
# optional stuff

[random_params]
rng_seed =


[crossover_params]
Expand All @@ -67,5 +70,6 @@ property_mutator_method =

[selector_params]
method =
tourn_size = 31 # Must be less than 32
tourn_prob = 0.5
[[method_params]]
tourn_size =
tourn_prob =
10 changes: 7 additions & 3 deletions gastop-config/error_config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ num_generations = 30
num_elite =
percent_mutation = .7
percent_crossover = .8
save_frequency = 5
save_filename_prefix = Recorded_States_

[monitor_params]
progress_display = 1
Expand All @@ -40,7 +42,7 @@ progress_display = 1
# optional stuff

[random_params]

rng_seed =

[crossover_params]
node_crossover_method =
Expand All @@ -62,7 +64,9 @@ property_mutator_method =
[[property_mutator_params]]
proportions =


[selector_params]
method =
tourn_size = 31 # Must be less than 32
tourn_prob = 0.5
[[method_params]]
tourn_size =
tourn_prob =
2 changes: 2 additions & 0 deletions gastop-config/init.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ num_generations = 30
num_elite = 1 # int, ~10 (the whole truss that get passed)
percent_crossover = 0.4 # float between 0 and 1
percent_mutation = 0.4 # float between 0 and 1
save_frequency = 5
save_filename_prefix = Recorded_States_

[random_params]
num_rand_nodes = 1 # int
Expand Down
9 changes: 6 additions & 3 deletions gastop-config/main_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ num_generations = 5
num_elite =
percent_mutation =
percent_crossover =
save_frequency = 5
save_filename_prefix = Recorded_States_

[monitor_params]
progress_display = 1
Expand All @@ -40,7 +42,7 @@ progress_display = 1
# optional stuff

[random_params]

rng_seed = 1138

[crossover_params]
node_crossover_method =
Expand All @@ -64,5 +66,6 @@ property_mutator_method =

[selector_params]
method =
tourn_size = 31 # Must be less than 32
tourn_prob = 0.5
[[method_params]]
tourn_size =
tourn_prob =
14 changes: 6 additions & 8 deletions gastop-config/struct_making_test_init.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,20 @@ cost_solver = cost_calc
num_threads = 4
pop_size = 1000
num_generations = 30
num_elite =
num_elite = 1
percent_mutation =
percent_crossover =
save_frequency = 5
save_filenames = 'save'
save_filename_prefix = Recorded_States_

[monitor_params]
progress_display = 1





# optional stuff

[random_params]

rng_seed =

[crossover_params]
node_crossover_method =
Expand All @@ -66,5 +63,6 @@ property_mutator_method =

[selector_params]
method =
tourn_size = 31 # Must be less than 32
tourn_prob = 0.5
[[method_params]]
tourn_size =
tourn_prob =
9 changes: 6 additions & 3 deletions gastop-config/struct_making_test_init2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ num_generations = 30
num_elite =
percent_mutation =
percent_crossover =
save_frequency = 5
save_filename_prefix = Recorded_States_

[monitor_params]
progress_display = 1
Expand All @@ -40,7 +42,7 @@ progress_display = 1
# optional stuff

[random_params]

rng_seed =

[crossover_params]
node_crossover_method =
Expand All @@ -64,5 +66,6 @@ property_mutator_method =

[selector_params]
method =
tourn_size = 31 # Must be less than 32
tourn_prob = 0.5
[[method_params]]
tourn_size =
tourn_prob =
9 changes: 6 additions & 3 deletions gastop-config/struct_making_test_init_sfr.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ num_generations = 5
num_elite =
percent_mutation =
percent_crossover =
save_frequency = 5
save_filename_prefix = Recorded_States_

[monitor_params]
progress_display = 1
Expand All @@ -40,7 +42,7 @@ progress_display = 1
# optional stuff

[random_params]

rng_seed =

[crossover_params]
node_crossover_method =
Expand All @@ -64,5 +66,6 @@ property_mutator_method =

[selector_params]
method =
tourn_size = 31 # Must be less than 32
tourn_prob = 0.5
[[method_params]]
tourn_size =
tourn_prob =
8 changes: 8 additions & 0 deletions gastop/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
"""__init__.py
This file is a part of GASTOp
Authors: Amlan Sinha, Cristian Lacey, Daniel Shaw, Paul Kaneelil, Rory Conlin, Susan Redmond
Licensed under GNU GPLv3.
This module imports the main classes so they are available at the top level of the package.
"""

from gastop.truss import Truss
from gastop.evaluator import Evaluator
from gastop.crossover import Crossover
Expand Down
13 changes: 11 additions & 2 deletions gastop/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
"""Runs the gastop program
This file runs scripts for GASTOp
Authors: Amlan Sinha, Cristian Lacey, Daniel Shaw, Paul Kaneelil, Rory Conlin, Susan Redmond
Licensed under GNU GPLv3.
"""
import argparse
import sys
from matplotlib import pyplot as plt
from gastop import GenAlg, utilities


Expand Down Expand Up @@ -32,6 +37,11 @@ def parse_args(args):


def main(args=sys.argv[1:]):
"""Runs the main GASTOp script, from the command line.
Reads and parses user input from command line, runs the code,
and prints and plots the resulting best truss.
"""

args = parse_args(args)
config = utilities.init_file_parser(args.config_path)
Expand Down Expand Up @@ -72,7 +82,6 @@ def main(args=sys.argv[1:]):
loads=config['evaluator_params']['boundary_conditions']['loads'],
fixtures=config['evaluator_params']['boundary_conditions']['fixtures'],
deflection=True)
plt.show()


if __name__ == '__main__':
Expand Down

0 comments on commit c95807a

Please sign in to comment.