Genetic generators
xopt.generators.ga.cnsga.CNSGAGenerator ¶
CNSGAGenerator(**kwargs)
Bases: Generator
Constrained Non-dominated Sorting Genetic Algorithm (CNSGA) generator.
Attributes:
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[pd.DataFrame] The DataFrame containing the offspring. population : Optional[pd.DataFrame] The DataFrame containing the population.
Methods:
create_children(self) -> List[Dict]
Create children for the next generation.
add_data(self, new_data: pd.DataFrame)
Add new data to the generator.
generate(self, n_candidates: int) -> List[Dict]
Generate a specified number of candidate samples.
write_offspring(self, filename: Optional[str] = None)
Write the current offspring to a CSV file.
write_population(self, filename: Optional[str] = None)
Write the current population to a CSV file.
load_population_csv(self, filename: str)
Load a population from a CSV file.
n_pop(self) -> int
Convenience property for population_size
.
Source code in xopt/generators/ga/cnsga.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
|
Attributes¶
xopt.generators.ga.cnsga.CNSGAGenerator.n_pop
property
¶
n_pop
Convenience property for population_size
.
Returns:
int The population size.
Functions¶
xopt.generators.ga.cnsga.CNSGAGenerator.add_data ¶
add_data(new_data)
Add new data to the generator.
Parameters:
new_data : pd.DataFrame The new data to be added.
Source code in xopt/generators/ga/cnsga.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
|
xopt.generators.ga.cnsga.CNSGAGenerator.create_children ¶
create_children()
Create children for the next generation.
Returns:
List[Dict] A list of dictionaries containing the generated children.
Source code in xopt/generators/ga/cnsga.py
103 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 |
|
xopt.generators.ga.cnsga.CNSGAGenerator.generate ¶
generate(n_candidates)
Generate a specified number of candidate samples.
Parameters:
n_candidates : int The number of candidate samples to generate.
Returns:
List[Dict] A list of dictionaries containing the generated samples.
Source code in xopt/generators/ga/cnsga.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
|
xopt.generators.ga.cnsga.CNSGAGenerator.load_population_csv ¶
load_population_csv(filename)
Load a population from a CSV file.
Parameters:
filename : str The file path to load the population from.
Source code in xopt/generators/ga/cnsga.py
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
|
xopt.generators.ga.cnsga.CNSGAGenerator.write_offspring ¶
write_offspring(filename=None)
Write the current offspring to a CSV file.
Parameters:
filename : str, optional The file path to save the offspring. If None, a timestamped filename is generated.
Source code in xopt/generators/ga/cnsga.py
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
|
xopt.generators.ga.cnsga.CNSGAGenerator.write_population ¶
write_population(filename=None)
Write the current population to a CSV file.
Parameters:
filename : str, optional The file path to save the population. If None, a timestamped filename is generated.
Source code in xopt/generators/ga/cnsga.py
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
|