M codes/README.md => codes/README.md +12 -14
@@ 6,29 6,26 @@ constrained problems. Cargo is used for managing the dependencies.
# How to run
-To run the tsp, go into the constr_hw02 folder, ie. `cd tsp_hw01`,
-then use `cargo run --release -- srank|moe problem`,
-Supported problems are: `g06`, `g08`, `g11`, `g24`.
+To run the contr, go into the constr_hw02 folder, ie. `cd constr_hw02`,
+then use `cargo run --release -- srank|nsga|nsga_improved|nsga_constr|nsga_multi problem`,
+Supported problems are: `g04`, `g05` `g06`, `g08`, `g09`, `g11` and `g24`.
So for example: `cargo run --release -- srank g06`
# Solutions
-The solution is then saved to `constr_hw01/solutions/<instance>`,
+The solution is then saved to `constr_hw02/solutions/<instance>`,
csv file with best candidate fitness (only feasible candidates
can be saved) and next to it is file with faction of feasible
candidates in each iteration.
# Plotting
-The solutions might be plotted by using `tsp_plotter` program.
-`cd tsp_plotter` and then `cargo run --release -- <feature>`,
-where feature is one of:
-```
-```
-The features are hardcoded in the code and used in the report,
-they say what algorithms and instances should be used in a given plot.
-They are taken from the `constr_hw02` folder.
+The solutions might be plotted by using `py_plotter` program.
+`cd py_plotter` and then `python3 plotter.py <json configuration>`,
+The configurations are available in the same folder. For generating
+the probability of success graphs, `target_proximity_plotter.py` is utilized.
+It's usage is the same as `plotter.py`, but it uses different json fields.
The name of the plotter is same as used for hw01 as the plotting itself is the same.
@@ 43,10 40,11 @@ python3 ./plotter.py config_feasible_g11.json
python3 ./plotter.py config_feasible_g06.json
python3 ./plotter.py config_feasible_g05.json
python3 ./plotter.py config_best_g09.json
+python3 ./target_proximity_plotter.py config_target_proximity_comprehensive_no_std.json
```
-Now all the csv solutions are in `constr_hw01/solutions` and all the plots are in
-`tsp_plotter/plots`
+Now all the csv solutions are in `constr_hw02/solutions` and all the plots are in
+`py_plotter/plots`
The graphs won't be 1:1, because randomness is involved and the seeds haven't been captured
and aren't configurable.
M codes/py_plotter/plotter.py => codes/py_plotter/plotter.py +6 -6
@@ 230,9 230,9 @@ class ConstraintOptimizationPlotter:
color=combined_color,
alpha=self.config['plot_settings']['alpha_fill'])
- ax.set_xlabel(self.config['plot_settings']['xlabel'], fontsize=14)
- ax.set_ylabel(self.config['plot_settings']['ylabel'], fontsize=14)
- ax.set_title(self.config['plot_settings']['title'], fontsize=16)
+ ax.set_xlabel(self.config['plot_settings']['xlabel'], fontsize=18)
+ ax.set_ylabel(self.config['plot_settings']['ylabel'], fontsize=18)
+ ax.set_title(self.config['plot_settings']['title'], fontsize=20)
# Set log scale if requested
if self.config['plot_settings'].get('log_x', False):
@@ 245,14 245,14 @@ class ConstraintOptimizationPlotter:
ax.yaxis.set_major_formatter(plt.FuncFormatter(lambda x, p: f'{x:.1f}%'))
# Set tick label font sizes
- ax.tick_params(axis='both', which='major', labelsize=12)
- ax.tick_params(axis='both', which='minor', labelsize=10)
+ ax.tick_params(axis='both', which='major', labelsize=16)
+ ax.tick_params(axis='both', which='minor', labelsize=14)
if self.config['plot_settings']['grid']:
ax.grid(True, alpha=0.3)
if self.config['plot_settings']['legend']:
- ax.legend()
+ ax.legend(fontsize=14)
plt.tight_layout()
M codes/report.md => codes/report.md +13 -22
@@ 70,7 70,7 @@ where in case of NSGA-II `evaluate()` means to obtain the non-dominated fronts a
# Used operators
-Since the chosen problems are real problems, real representation has been used.
+Since the chosen problems are using real numbers, real representation has been used.
For mutation, the solution is changed with random sample from normal distribution
with zero mean.
@@ 139,7 139,7 @@ Later in the algorithm run, the bounds are also enforced. Specifically for cross
When mutation or crossover produce results out of bounds, the operation is retried five times.
If all produce results out of bounds, the result is forcibly bounded. This has been done
because some problems, such as `g04` were escaping the bounds and finding different optima,
-much lower than the originally reported optima. It is hasn't been check if this is because there
+much lower than the originally reported optima. It is hasn't been checked if this is because there
are really better optima out of bounds or if there is a numerical instability causing this.
None of the best candidate evaluations contain infeasible solutions. This is also why some
of the graphs start only after few function evaluations, because a feasible solution has
@@ 163,17 163,16 @@ and standard deviation given according to the following table:
- g24 - `0.1`
As for runtime parameters, population had 250 individuals, each iteration
-generated 125 offsprings out of 125 parents. There were 1250 iterations,
+generated 125 offsprings out of 125 parents. There were 5000 iterations,
The number of iterations in stochastic ranking is 2 * population.
Probability of comparing fitness in stochastic ranking is 0.45 for most problems.
For g04 it was set to 0.65, because that led to significantly better results.
For g05, it is 0.2, because with 0.45 usually no feasible solution has been found.
To get the percentage deviation from the optimal value, because of negative values,
-the formula has been changed. Specifically in cases when the optimal value is below
-zero and the values cross zero, near zero the deviation would be zero. Because of that,
-in cases where optimal value is negative, the function has been shifted up by $-2 \cdot o$,
-where o is the optimal value. New optimal value is $o_{n} = -o$ and the data do not cross zero.
+the formula has been changed.
+In cases where optimal value is negative, the function has been shifted up by $-2 \cdot o$,
+where $o$ is the optimal value. New optimal value is $o_{n} = -o$ and the data do not cross zero.
Then the formula for deviation is $(x_{n} - o_{n}) / o_{n}$
First here is a chosen problem's percentage deviation, specifically of g09. This is one of the
@@ 183,7 182,10 @@ haarder problems, using 7 variables and 4 constraints.
The graph depicts the average values and it can be observed that at the beginning, the variance
is very large, but it's getting consistent in further iterations. That means the algorithms
-are working roughly as they should, prefering better candidates.
+are working roughly as they should, prefering better candidates. Moreover it can also be observed
+when the first feasible candidates are obtained. While NSGA constrained and NSGA are able to attain
+feasible solutions quite early, NSGA improved, S-Rank and NSGA with multiple objectives attain
+results only later.
\newpage
@@ 229,17 231,6 @@ at least early in the run (see the next section), but it does produce
worse results, suggesting that it prefers feasible solutions even if they aren't
as good. This really is the case when looking at the conditions.
-## Comparing g11 with g06
-
-`g11` is special in the regard that it has an
-equality condition that is harder to satisfy.
-So here only `g11` is compared with `g06`.
-A fraction of feasible solutions for each iteration
-has been obtained, as well as average constraint violation.
-
-Here is a plot with fraction of feasible solutions in iteration for both
-problems:
-
## Comparing feasibility in the population
One important metric is how many individuals in the population
@@ 254,14 245,12 @@ function. Equality is harder to satisfy, because the area of feasible solutions
is smaller. And through the mutation it's much more probable to leave the
feasible area than to stay inside of it.
-\newpage
-
{latex-placement="H"}
{latex-placement="H"}
\newpage
-As can be seen from the graphs, the NSGA-II multi approach is not so well,
+As can be seen from the graphs, the NSGA-II multi approach is not doing so well,
this could be because it tries to mostly optimize the original function and/or only one of the constraints.
This is because it can get more reward for doing so and the third objective can be left above zero, leading
to infesiable candidates. Still, it does produce some feasible candidates as can be seen from the previous
@@ 328,3 317,5 @@ is that Gemini has also been utilized, not only Claude.
- https://sciences.uodiyala.edu.iq/uploads/00%20Abdullah%20New%20website/Lectures/comp/%D9%85%D8%AD%D8%A7%D8%B6%D8%B1%D8%A7%D8%AA%20%D8%AF%20%D8%B2%D9%8A%D8%A7%D8%AF%20%D8%B7%D8%A7%D8%B1%D9%82/%D8%A7%D8%AD%D8%AA%D8%B3%D8%A7%D8%A8%20%D8%AA%D8%B7%D9%88%D8%B1%D9%8A%203.pdf
- https://www.researchgate.net/figure/Blend-crossover-operator-BLX_fig1_226044085
- https://cw.fel.cvut.cz/wiki/_media/courses/a0m33eoa/cviceni/2006_problem_definitions_and_evaluation_criteria_for_the_cec_2006_special_session_on_constraint_real-parameter_optimization.pdf
+
+PS: I am sorry for submitting so late! I had trouble not procrastinating this homework as I didn't enjoy it as much as the first one. Sorry once more.