Genetic generators
xopt.generators.ga.cnsga.CNSGAGenerator ¶
CNSGAGenerator(**kwargs)
Bases: Generator
Constrained Non-dominated Sorting Genetic Algorithm (CNSGA) generator.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
The name of the generator. |
supports_multi_objective |
bool
|
Indicates if the generator supports multi-objective optimization. |
population_size |
int
|
The population size for the genetic algorithm. |
crossover_probability |
float
|
The probability of crossover. |
mutation_probability |
float
|
The probability of mutation. |
population_file |
Optional[str]
|
The file path to load the population from (CSV format). |
output_path |
Optional[str]
|
The directory path to save the population files. |
_children |
List[Dict]
|
The list of children generated. |
_offspring |
Optional[DataFrame]
|
The DataFrame containing the offspring. |
population |
Optional[DataFrame]
|
The DataFrame containing the population. |
Methods:
Name | Description |
---|---|
create_children |
Create children for the next generation. |
add_data |
Add new data to the generator. |
generate |
Generate a specified number of candidate samples. |
write_offspring |
Write the current offspring to a CSV file. |
write_population |
Write the current population to a CSV file. |
load_population_csv |
Load a population from a CSV file. |
n_pop |
Convenience property for |
Source code in xopt/generators/ga/cnsga.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
|
Attributes¶
xopt.generators.ga.cnsga.CNSGAGenerator.n_pop
property
¶
n_pop
Convenience property for population_size
.
Returns:
Type | Description |
---|---|
int
|
The population size. |
Functions¶
xopt.generators.ga.cnsga.CNSGAGenerator.add_data ¶
add_data(new_data)
Add new data to the generator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
new_data
|
DataFrame
|
The new data to be added. |
required |
Source code in xopt/generators/ga/cnsga.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
|
xopt.generators.ga.cnsga.CNSGAGenerator.create_children ¶
create_children()
Create children for the next generation.
Returns:
Type | Description |
---|---|
List[Dict]
|
A list of dictionaries containing the generated children. |
Source code in xopt/generators/ga/cnsga.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
|
xopt.generators.ga.cnsga.CNSGAGenerator.generate ¶
generate(n_candidates)
Generate a specified number of candidate samples.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_candidates
|
int
|
The number of candidate samples to generate. |
required |
Returns:
Type | Description |
---|---|
List[Dict]
|
A list of dictionaries containing the generated samples. |
Source code in xopt/generators/ga/cnsga.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
|
xopt.generators.ga.cnsga.CNSGAGenerator.load_population_csv ¶
load_population_csv(filename)
Load a population from a CSV file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename
|
str
|
The file path to load the population from. |
required |
Source code in xopt/generators/ga/cnsga.py
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
|
xopt.generators.ga.cnsga.CNSGAGenerator.write_offspring ¶
write_offspring(filename=None)
Write the current offspring to a CSV file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename
|
str
|
The file path to save the offspring. If None, a timestamped filename is generated. |
None
|
Source code in xopt/generators/ga/cnsga.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
|
xopt.generators.ga.cnsga.CNSGAGenerator.write_population ¶
write_population(filename=None)
Write the current population to a CSV file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename
|
str
|
The file path to save the population. If None, a timestamped filename is generated. |
None
|
Source code in xopt/generators/ga/cnsga.py
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
|