Skip to content

Commit

Permalink
Updated doc strings
Browse files Browse the repository at this point in the history
  • Loading branch information
Susan Redmond authored and Susan Redmond committed Jan 10, 2019
1 parent 21998db commit 7281c40
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 21 deletions.
2 changes: 1 addition & 1 deletion GASTOp.py
Expand Up @@ -11,7 +11,7 @@
animation_path = '/Users/susanredmond/Desktop/APC524_FinalProject/animation' #needs to be full path
# Parse input paramters from init.txt file
#init_file_path = 'gastop-config/struct_making_test_init2.txt'
init_file_path = 'gastop-config/struct_making_test_init_sfr_cantilevered.txt'
init_file_path = 'gastop-config/struct_making_test_init_sfr.txt'

config = utilities.init_file_parser(init_file_path)

Expand Down
8 changes: 4 additions & 4 deletions gastop-config/struct_making_test_init_sfr.txt
Expand Up @@ -24,17 +24,17 @@ cost_solver = cost_calc

[ga_params]
num_threads = 4
pop_size = 1000
num_generations = 2
pop_size = 10
num_generations = 10
num_elite =
percent_mutation =
percent_crossover =
save_frequency = 5
save_filename_prefix = Recorded_States_

[monitor_params]
progress_fitness = False
progress_truss = False
progress_fitness = True
progress_truss = True



Expand Down
51 changes: 36 additions & 15 deletions gastop/progmon.py
Expand Up @@ -7,9 +7,7 @@
"""

import matplotlib.pyplot as plt
from matplotlib import style
import numpy as np
from matplotlib.animation import FuncAnimation
import collections


Expand All @@ -33,18 +31,18 @@ def __init__(self, progress_fitness, progress_truss, num_generations, domain=Non
object instatiation.
Args:
progress_fitness: boolean argument, if true the minimum fitness
score of the population is plotted each iteration
progress_truss: boolean argument, if true the truss corresponding to
the minimum fitness score is displayed each iteration
num_generations: integer, indicates the number of generations, used
when initializing the progress_fitness figure
domain: numpy array, indicates bounds of design area, used when
progress_truss is true
loads: numpy array, indicates magnitude and direction of loads
applied to user_spec_nodes, used when progress_truss is true
fixtures: numpy array, indicates fixed DOFs of user_spec_nodes, used
when progress_truss is true
progress_fitness (boolean): if true the minimum fitness score of the
population is plotted each iteration
progress_truss (boolean): if true the truss corresponding to the
minimum fitness score is displayed each iteration
num_generations (integer): indicates the number of generations, used
when initializing the fitness figure
domain (numpy array): indicates bounds of design area, used when
*progress_truss* is true
loads (numpy array): indicates magnitude and direction of loads
applied to *user_spec_nodes*, used when *progress_truss* is true
fixtures (numpy array): indicates fixed DOFs of *user_spec_nodes*,
used when *progress_truss* is true
Returns:
Nothing
Expand All @@ -54,7 +52,6 @@ def __init__(self, progress_fitness, progress_truss, num_generations, domain=Non
self.progress_truss = progress_truss
self.num_gens = num_generations
self.pop_progress = collections.defaultdict(dict)
#self.dict_headings = ['Generation','Best Truss','Best Fitness Score','Population Median Fitness Score','Population Fitness Score Range']

self.pop_start = []
self.box_size = []
Expand Down Expand Up @@ -89,6 +86,30 @@ def __init__(self, progress_fitness, progress_truss, num_generations, domain=Non

def progress_monitor(self, current_gen, population):

"""Updates progress monitor plots
Function is passed the sorted population and plots either the current
generation's best fitness score, best truss, or both. If the truss is
displayed, the plot method of the truss object is called but passed the
figure instantiated in the init method.
Args:
progress_fitness (boolean): if true the minimum fitness score of the
population is plotted each iteration
progress_truss (boolean): if true the truss corresponding to the
minimum fitness score is displayed each iteration
num_generations (integer): indicates the number of generations, used
when initializing the *progress_fitness* figure
domain (numpy array): indicates bounds of design area, used when
*progress_truss* is true
loads (numpy array): indicates magnitude and direction of loads
applied to *user_spec_nodes*, used when *progress_truss* is true
fixtures (numpy array): indicates fixed DOFs of *user_spec_nodes*,
used when *progress_truss* is true
Returns:
Nothing
"""
try: #if being called by utilities you dont want to do this block

fitscore = [i.fitness_score for i in population]
Expand Down
7 changes: 7 additions & 0 deletions gastop/truss.py
Expand Up @@ -210,6 +210,13 @@ def plot(self, domain=None, loads=None, fixtures=None,
load_scale (float): Size load vector arrows should be scaled by.
def_scale (float): Scaling for deflections. *def_scale*=1
means actual size, larger than 1 magnifies.
ax (axis): Axis to plot truss on, if an axis is passed to the
function, the function is being called by ProgMon and *prog* is
set to 1. If axis is none, a new one is created.
fig (fig): Figure belonging to the axis.
setup_only (boolean): If true, only the loads and fixtures are
plotted.
Returns:
None
Expand Down
2 changes: 1 addition & 1 deletion gastop/utilities.py
Expand Up @@ -29,7 +29,7 @@ def save_gif(progress_history, progress_fitness, progress_truss, animation_path,
Args:
progress_history (dictionary of dictionaries): population statistics and
best truss from each generation.
best truss from each generation.
progress_fitness (boolean): indicates whether to plot the fitness score.
progress_truss (boolean): indicates whether to plot the current truss.
animation_path (string): path to the file where the gif should be created.
Expand Down

0 comments on commit 7281c40

Please sign in to comment.