Prepare the data
Define a toy knapsack problem with item values, weights and a fixed capacity.
Search with variation. Keep the constraints visible.
A genetic algorithm evolves candidate solutions through selection, crossover and mutation. A small constrained optimisation problem makes feasibility and stochastic convergence measurable.
Learning concept · Not a validated service
A genetic algorithm evolves candidate solutions through selection, crossover and mutation. A small constrained optimisation problem makes feasibility and stochastic convergence measurable.
A possible application for optimisation instructors: Let learners explore how evolutionary search handles simple resource constraints. This extension is not delivered by the supplied starter.
Define a toy knapsack problem with item values, weights and a fixed capacity.
Implement population initialisation, fitness, selection, crossover, mutation and an explicit stopping rule.
Compare best feasible fitness with exhaustive search on a tiny case and repeat across seeds.
Display feasible candidate solutions and fitness history rather than promising an optimum.
The supplied starter creates 800 synthetic binary-classification rows with ten numeric features. It makes a stratified train/test split, fits a scaled RandomForestClassifier pipeline and prints a classification report.
model = Pipeline(
steps=[
("scale", StandardScaler()),
("classifier", RandomForestClassifier(
n_estimators=250, random_state=RANDOM_STATE)),
]
)
model.fit(X_train, y_train)
predictions = model.predict(X_test)
print(classification_report(y_test, predictions))The source trains a supervised forest and has no evolutionary population or fitness loop. Synthetic binary classification does not establish performance on the proposed application. The source report uses one split; it supplies no deployment or real-world validation.
Proposed extension: Let learners explore how evolutionary search handles simple resource constraints.
This is a potential application pathway, not a delivered product. The supplied starter does not implement this service or validate it with real users.
Networkers Home runs this topic inside its AI Engineer Course, with placement support and hands-on labs.