# 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 [dict], and nested dictionaries are indicated by nested squared brackets, [[nested dict]]. Each dictionary contains multiple arguments indicated by key: value. If the value is an integer, float, or string, simply input the value without quotation marks. For instance, key: 3, key: 3.14, or key: pi. If the value is a numpy array, input the value as an array in list format, within single quotes, like key: '[[3.14 3.14],[3.14 3.14]]'.

For instance, the config file:

[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:

{'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 Parameters¶

[general] contains the following parameters:

user_spec_nodes:
(nx3 numpy array of floats) User-specified nodes (nodes with provided loads and
displacement boundary conditions) in the format '[[x1 y1 z1],[x2 y2 z2],...,[xn yn zn]]'.
loads:(nx6 numpy array of floats) The forces and moments acting on each user-specified
node in the format
'[[Fx1,Fy1,Fz1,Mx1,My1,Mz1][Fx2,Fy2,Fz2,Mx2,My2,Mz2],...,[Fxn,Fyn,Fzn,Mxn,Myn,Mzn]]'.
fixtures:(nx6 numpy array of ints) The translational and rotational displacements for each
user-specified node in the format '[[tx1,ty1,tz1,rx1,ry1,rz1],[tx2,ty2,tz2,rx2,ry2,rz2],...,[txn,tyn,tzn,rxn,ryn,rzn]]'.
Here tx1 is the translational degree of freedom in the x direction of the first
user-specified node, and rx1 is the rotational degree of freedom about the x-axis
of the first user-specified node. A 1 indicates fixed, while a 0 indicates
the node is free to move along or about the corresponding degree of freedom.
num_rand_nodes:(int) Maximum number of random nodes.
num_rand_edges:(int) Maximum number of random edges.
properties_path:
(str) Path to the properties CSV, relative to the location of the config file. For example, ../properties.csv.
domain:(3x2 numpy array of floats) Allowable domain in the format
'[[xmin xmax],[ymin ymax],[zmin zmax]]'.

### Fitness Function Parameters¶

[fitness_params] contains the following parameters (see fitness_function):

equation: parameters: (str) Method for calculating fitness. Options: weighted_sum, sphere, rosenbrock, rastrigin. (dict) Additional fitness function parameters. (int) Desired factor of safety. (1xn numpy array of ints) Array of nodes numbers for which deflection should be minimized. If empty, defaults to all. (float) Penalty weight for low fos. Only applied if truss.fos < goal_fos. (float) Penalty applied to mass. Relative magnitude of w_mass and w_fos determines importance of minimizing mass vs maximizing fos. (float) Penalty applied to deflections. If scalar, applies the same penalty to all critical nodes. Can also be an array the same size as critical_nodes in which case different penalties will be applied to each node.

### Evaluator Parameters¶

[evaluator_params] contains the following parameters (see evaluator):

struct_solver: mass_solver: (str) Method for solving truss. Options: mat_struct_analysis_DSM Default: mat_struct_analysis_DSM (str) Method of calculating the mass of a truss. Options: mass_basic Default: mass_basic (str) Method of determining interferences. Options: blank_test, interference_ray_tracing Default: blank_test (str) Method of calculating the cost of a truss. Options: cost_calc Default: cost_calc

### Genetic Algorithm Parameters¶

[ga_params] contains the following parameters (see gen_alg):

num_threads: pop_size: (int) Number of threads. If equal to one, the GenAlg.run() method will execute in serial. If greater than one, it will run in parallel. (int) Number of trusses in each generation. (int) Number of generations to run. (int) Number of fittest trusses to carry over to the next generation without modification. (float) Percent of trusses in the next generation (after subtracting elites) to be derived from mutation of current trusses. (float) Percent of trusses in the next generation (after subtracting elites) to be derived from crossover of current trusses. (int) Number of generations after which the population and config are saved to .json files. (str) Prefix for the save filenames. For example, save_.

### Progress Monitor Parameters¶

[monitor_params] contains the following parameters (see progress_monitor):

progress_fitness:
(bool) Progress monitor display mode, if true displays best fitness score of the population each generation.
progress_truss:(bool) Progress monitor display mode, if true displays the truss with the best fitness score each generation.

## Optional Parameters¶

### Random Generation Parameters¶

[random_params] contains the following parameters:

### Crossover Parameters¶

[crossover_params] contains the following parameters (see crossover):

node_crossover_method:
(str) Method for performing node crossover. Options: uniform_crossover, single_point_split, two_points_split Default: uniform_crossover
edge_crossover_method:
(str) Method for performing edge crossover. Options: uniform_crossover, single_point_split, two_points_split Default: uniform_crossover
property_crossover_method:
(str) Method for performing edge crossover. Options: uniform_crossover, single_point_split, two_points_split Default: uniform_crossover
node_crossover_params:
edge_crossover_params:
property_crossover_params:

### Mutator Parameters¶

[mutator_params] contains the following parameters (see mutator):

node_mutator_method:
(str) Method for performing node mutation. Options: gaussian, pseudo_bit_flip, shuffle_index Default: gaussian
edge_mutator_method:
(str) Method for performing edge mutation. Options: gaussian, pseudo_bit_flip, shuffle_index Default: pseudo_bit_flip
property_mutator_method:
(str) Method for performing property mutation. Options: gaussian, pseudo_bit_flip, shuffle_index Default: pseudo_bit_flip
node_mutator_params:
node_mutator_params[‘std’]:
(float) Standard deviation for mutation. If array-like, std[i] is used as the standard deviation for array[:,i].
edge_mutator_params:
edge_mutator_params[‘proportions’]:
(float) Probability of a given entry being mutated.
property_mutator_params:
property_mutator_params[‘proportions’]:
(float) Probability of a given entry being mutated.

### Selector Parameters¶

[selector_params] contains the following parameters (see selector):

method: (str) Method for performing selection. Options: inverse_square_rank_probability, tournament Default: inverse_square_rank_probability (int) The number of truss indices in each tournament. Must be less than 32. (float) The probability of the fittest truss in a tournament to be selected.

## Properties Parsing¶

While parsing the config file, GASTOp will read the path to a file that contains the user-specified property information from a CSV file. The file exists by default as properties.csv with a few available material options:

beam material OD (m) ID (m) elastic_modulus (Pa) yield_strength (Pa) dens (kg/m^3) poisson_ratio cost (\$/m)
0 steel 0.025 0.02 200000000000 250000000 8050 0.3 1
1 steel 0.012 0.01 200000000000 250000000 8050 0.3 0.75
2 aluminum 0.025 0.02 69000000000 95000000 2700 0.32 2
3 aluminum 0.012 0.01 69000000000 95000000 2700 0.32 1.5
4 2024 aluminum 0.042 0.032 69000000000 276000000 2700 0.32 3

Adding additional materials is as simple as adding a row to the default file, with all values separated by commas. One could also alternatively create a new properties file, duplicating the format of the default, replacing all material data, and specifying the path to the new properties file in the config file.