Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Progresively interactive NSGA-II #656

Open
wants to merge 114 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
38877d2
Development environment set up with pytest
kroppian Nov 2, 2023
c020ccc
Adding dummy functions that mock up the I/O of value functions
kroppian Nov 9, 2023
780d709
Passing smoke test for problem constructor
kroppian Nov 16, 2023
39f6adf
Have the solutions (P) being sorted by ranking
kroppian Nov 16, 2023
3803c94
Now also testing whether the P in the result are sorted properly
kroppian Nov 16, 2023
f485f50
Added test for the objective function
kroppian Nov 16, 2023
95935c1
Trying to standardize P versus F
kroppian Nov 16, 2023
e657a94
Adding the value fucnction to the optimization constructors
kroppian Nov 16, 2023
6039470
Have the inequality constraint basically working (- some rounding err)
kroppian Nov 30, 2023
8285583
Fixed the false negative test
kroppian Nov 30, 2023
7d6a7c1
Fixing false negative test in the objective function
kroppian Nov 30, 2023
20df002
Have a basic equality test and implementation in place
kroppian Nov 30, 2023
1d83d4b
Successfully ran an optimization smoke test, though the values look bad
kroppian Nov 30, 2023
1e4b0b2
Have first step of a plotter working
kroppian Nov 30, 2023
57246d0
Have a contour graph working... which isn't want I wanted to do at all
kroppian Dec 5, 2023
471c2fe
Have the contour lines lined up with P!
kroppian Dec 5, 2023
6a57e2e
Experimenting with different SOO optimization techniques
kroppian Dec 6, 2023
affecaa
Pulling the objective function out of the _evaluate function
kroppian Dec 7, 2023
5331c3c
Made a test for the independent objective function, plus opt smoke test
kroppian Dec 7, 2023
ba169c2
Pulled the equality constraint function into a stand alone function
kroppian Dec 7, 2023
9fd8dbb
Pulled the inequality constraints out of the _evaluate func
kroppian Dec 7, 2023
063aa3d
Finished basic 1D array compatibility
kroppian Dec 7, 2023
c499954
Have a smoke test for scipy's minimize working
kroppian Dec 7, 2023
f867b38
Successfully tested the scipy solver methods!
kroppian Dec 7, 2023
512b2d4
Refactoring a few things
kroppian Dec 7, 2023
6d56ff2
More refactoring
kroppian Dec 7, 2023
cc0c985
Making the value function plotter generic
kroppian Dec 7, 2023
1e14ddb
Utter mess
kroppian Dec 8, 2023
13ccec0
Rooted out that nasty problem with P's dimensionality
kroppian Dec 8, 2023
37f7b40
Changed vf for the value function library to mvf to avoid confusion
kroppian Dec 8, 2023
f67da61
Pulling more functionality into the create_vf functions
kroppian Dec 8, 2023
f92047a
Finalizing plotting
kroppian Dec 8, 2023
9e14941
Adding some test data to play with
kroppian Dec 13, 2023
f3413c4
have the first veresion of the polynomial value function
kroppian Dec 19, 2023
84e736a
Making skeleton code for creating polynomial VF
kroppian Dec 20, 2023
f143efb
Removing a near duplicate test
kroppian Dec 20, 2023
1df2f84
Tidying up testing and vf generation code
kroppian Dec 20, 2023
bb28345
Have the inequality constraint test set up
kroppian Dec 21, 2023
547741e
Pulled the part of the poly value function that calculates S
kroppian Dec 21, 2023
04e621a
Fixing several compatibility problems
kroppian Dec 21, 2023
e48d53f
Got a first version of polynomial inequality constraints working
kroppian Dec 21, 2023
e8985f1
Have the 2D version of the poly constraint working
kroppian Dec 21, 2023
98fc8c3
Have a basic equality constraint working
kroppian Dec 21, 2023
810ac7b
Fixing the scipy optimization for polynomial value functions
kroppian Dec 22, 2023
2a080a2
Magically rewrote the S calc function after much head scratching
kroppian Jan 2, 2024
43e507f
Have the product calculator working
kroppian Jan 3, 2024
57bda00
Adding some dimensionality tests and squeezing S output
kroppian Jan 3, 2024
e6e73ae
Fixing (untransposing) the linear value function, and adding +tests
kroppian Jan 4, 2024
8877095
Fixing errors in the S calculation
kroppian Jan 4, 2024
ebccef5
Updating testing data for the new utility function
kroppian Jan 4, 2024
03829c1
Fixing a bug in the inequality constraint calcuation
kroppian Jan 5, 2024
bd93c88
I added bounds to the scipy opt, and pymoo optimization for poly vf
kroppian Jan 8, 2024
ae639f4
Making the optimization a bit quickier in a lazy way
kroppian Jan 8, 2024
71afc8c
Cleaning up the vf tester script
kroppian Jan 8, 2024
1fe842f
Making the result of the vf into a more complete result object
kroppian Jan 9, 2024
b3a683c
Added a maximization/minimization parameter to vf creation
kroppian Jan 9, 2024
8681711
Made minimization the default
kroppian Jan 9, 2024
890065a
Have the first basic version of a comparator working
kroppian Jan 9, 2024
7932b13
Merge branch 'feature/linear-value-func' into develop
kroppian May 7, 2024
c224395
Have ZDT1 with the dashboard visualizer set up
kroppian May 7, 2024
327aa25
Adding a class for PI-NSGA-II-VF
kroppian May 7, 2024
eae1dac
Selecting eta most scattered points + plotting
kroppian May 7, 2024
5fa4c21
First swing at the rank prompt
kroppian May 14, 2024
b687ba5
Have VF optimization tied into the optimization with some crude plots
kroppian May 14, 2024
0a366cd
Fixing various issues with plotting
kroppian May 14, 2024
93c3876
Allowing the user to see the solutions to choose among
kroppian May 14, 2024
aa74486
Have the grey trail of previous generations working
kroppian May 16, 2024
9f935a4
Fixed the plotting scale
kroppian May 16, 2024
53e49df
Fixing plotting plus first steps for validation
kroppian May 21, 2024
bba8b83
Adding a validation function
kroppian May 21, 2024
acb41ba
Hooked a custom dominator function into pi-nsga-ii
kroppian May 21, 2024
e71c03a
Pulling the vf dominator out of the pi-nsga-2 code
kroppian May 21, 2024
0043226
Now have the value function parameters hooked into the domination obj
kroppian May 21, 2024
8d48b52
Have things working... perhaps
kroppian May 24, 2024
fa0bfaa
Another max/min bug. (I think it's working!)
kroppian May 26, 2024
b38412a
Adding updates from pico
kroppian Jul 1, 2024
3593edf
Forgot to incorporate nds code as well
kroppian Jul 1, 2024
ec8f31c
Adding a half-working domination graph
kroppian Jul 2, 2024
f9a2368
Fixing a bug with the value function dominance
kroppian Jul 2, 2024
b3df485
Forgot some supporting code for the domination plot
kroppian Jul 2, 2024
dadfb7f
Pairwise Comparison
e-spinner Jul 3, 2024
bd14295
Have VF and optimization methods integrated into the optimization
kroppian Jul 3, 2024
e40dba8
Updating the VF optimization from min to max
kroppian Jul 3, 2024
1237752
Adding hessian matrix for trust constraint method
kroppian Jul 3, 2024
f41f9ba
Moving this to the pymoo example directory
kroppian Jul 3, 2024
5e18eb0
Tidying up this exmaple code
kroppian Jul 3, 2024
233caa8
Making methods non-static + some variable name tweaks
kroppian Jul 3, 2024
bc0f562
fixed flattening bug
e-spinner Jul 3, 2024
be43ad9
Freshing this up a bit
kroppian Jul 3, 2024
58fb9f1
Removing min/max option
kroppian Jul 3, 2024
feb7afd
Threading a delta variable throughout the value function
kroppian Jul 5, 2024
b33bc0d
Have partial ordering working
kroppian Jul 5, 2024
f533fc2
Added some skeleton code for an abstract class
kroppian Jul 9, 2024
cc1e5dd
AutomatedDM + documentation
e-spinner Jul 11, 2024
a4c64f8
Switched to proper ranking type
e-spinner Jul 17, 2024
ec5ff04
Tied rankings working
e-spinner Jul 17, 2024
a6bd161
Incorporating chagnes to max eps, ranking, and validation
kroppian Jul 17, 2024
757b9b0
Fixing the index starting at 1 bug, + adding a final ranking message
kroppian Jul 18, 2024
4f7c928
Adding an option for choosing the display sign for prompts
kroppian Jul 18, 2024
84f7e4c
Merge branch 'feature/pair-wise-comparator' of github.com:kroppian/py…
kroppian Jul 18, 2024
885b797
Merge branch 'feature/automated-dm' of github.com:kroppian/pymoo-pi-e…
kroppian Jul 19, 2024
d263540
AutomatedDM + pairwise ranking
e-spinner Jul 24, 2024
8b91c24
Fixing yet another failed run falling through the cracks
kroppian Jul 31, 2024
f82a691
Updated testing script
e-spinner Aug 1, 2024
2a5825a
Merge branch 'pinsga2/pytest' of github.com:kroppian/pymoo-pi-emo int…
kroppian Aug 1, 2024
3077aab
Cleaning examples and helper code
kroppian Aug 12, 2024
8df9c15
Cleaning up temporary code changes
kroppian Aug 12, 2024
f7bfe66
Fixing an infinite loop bug when no fit can be found
kroppian Aug 13, 2024
f47963d
Have smarter warnings integrated into the algorithm
kroppian Aug 13, 2024
d11a0f1
Fixing a bug with tau being hard coded
kroppian Aug 13, 2024
8574c3e
Polishing documentation
kroppian Aug 13, 2024
936f106
Removing the work-in-progress dashboard module for now
kroppian Aug 13, 2024
3e0504c
Remove Dominator from NDS
e-spinner Sep 5, 2024
6d09565
Custom VFSurvival for compilation bug
e-spinner Sep 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/source/algorithms/algorithms.csv
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
:ref:`Improved Stochastic Ranking Evolutionary Strategy <nb_isres>`, ISRES, single, x, An improved version of SRES being able to deal dependent variables efficiently.
:ref:`NSGA-II <nb_nsga2>`, NSGA2, multi, x, Well-known multi-objective optimization algorithm based on non-dominated sorting and crowding.
:ref:`R-NSGA-II <nb_rnsga2>`, RNSGA2, multi, x, An extension of NSGA-II where reference/aspiration points can be provided by the user.
:ref:`PI-NSGA-II <nb_pinsga2>`, PINSGA2, multi, x, An interactive version of NSGA-II that uses user preference to guide the optimization towards desired solutions.
:ref:`NSGA-III <nb_nsga3>`, NSGA3, many, x, An improvement of NSGA-II developed for multi-objective optimization problems with more than two objectives.
:ref:`U-NSGA-III <nb_unsga3>`, UNSGA3, many, x, A generalization of NSGA-III to be more efficient for single and bi-objective optimization problems.
:ref:`R-NSGA-III <nb_rnsga3>`, RNSGA3, many, x, Allows defining aspiration points for NSGA-III to incorporate the user's preference.
Expand Down
203 changes: 203 additions & 0 deletions docs/source/algorithms/moo/pinsga2.ipynb

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions docs/source/references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -754,3 +754,16 @@ @article{mosade
year={2010},
publisher={Springer}
}



@article{piemovf,
title={An interactive evolutionary multiobjective optimization method based on progressively approximated value functions},
author={Deb, Kalyanmoy and Sinha, Ankur and Korhonen, Pekka J and Wallenius, Jyrki},
journal={IEEE Transactions on Evolutionary Computation},
volume={14},
number={5},
pages={723--739},
year={2010},
publisher={IEEE}
}
90 changes: 90 additions & 0 deletions examples/algorithms/moo/pinsga2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
from pymoo.algorithms.moo.pinsga2 import PINSGA2
from pymoo.optimize import minimize
from pymoo.problems.multi import ZDT1
from pymoo.problems.multi import ZDT3
import pymoo.gradient.toolbox as anp
import matplotlib.pyplot as plt
from pymoo.visualization.scatter import Scatter
from pymoo.util import value_functions as mvf


# Additional example from original PI-EMO-VF literature
class ZDT1_max(ZDT1):

def _evaluate(self, x, out, *args, **kwargs):
f1 = x[:, 0]
g = 1 + 9.0 / (self.n_var - 1) * anp.sum(x[:, 1:], axis=1)
f2 = (10 - anp.power((f1 * g), 0.5)) / g

f1 = -1 * f1;
f2 = -1 * f2;

out["F"] = anp.column_stack([f1, f2])



def plot_eta_F(context, algorithm):


# Next highlight the eta selctions
if len(algorithm.eta_F) > 0:

# Plot the historical PO fronts
plot = Scatter().add(algorithm.historical_F, facecolors= '#f5f5f5', edgecolors='#f5f5f5')

# The current PO front
plot.add(algorithm.paused_F)

# Starred items for the DM
plot.add(algorithm.eta_F, s=500, marker='*', facecolors='red')


else:
F = algorithm.pop.get("F")
plot = Scatter().add(F)


plot.plot_if_not_done_yet()

return plot.fig


def plot_vf(context, algorithm):

# This option prevents us from plotting vf every single
if not algorithm.vf_plot_flag and algorithm.vf_plot:
return algorithm.vf_plot

# This option is if a vf has been calculated and we want to plot it
elif len(algorithm.eta_F) > 0 and (algorithm.vf_res is not None) and algorithm.vf_plot_flag:
plot = mvf.plot_vf(algorithm.eta_F * -1, algorithm.vf_res.vf, show=False)

algorithm.vf_plot_flag = False;

algorithm.vf_plot = plot.gcf()

return plot.gcf()

# This option is if we have not calculated a vf and we just want to show the PF
else:
F = algorithm.pop.get("F")

plt.scatter(F[:, 0], F[:, 1], color='blue')

algorithm.vf_plot = plt.gcf()

return algorithm.vf_plot


problem = ZDT3()

# opt_method can be trust-constr, SLSQP, ES, or GA
# vf_type can be linear or poly
algorithm = PINSGA2(pop_size=30, opt_method="trust-constr", vf_type="poly")

res = minimize(problem,
algorithm,
('n_gen', 200),
seed=1,
verbose=True)

70 changes: 70 additions & 0 deletions examples/misc/value_functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
from pymoo.util import value_functions as mvf
import numpy as np

## Examples from Sinha's code
P = np.array([[3.6, 3.9],
[2.5, 4.1],
[5.5, 2.5],
[0.5, 5.2],
[6.9, 1.8]])
ranks = [1,2,2,3,4]
#ranks = [1,4,3,5,2]

# This is a great example. Illustrates the when polynomial versus linear works
# when the problem is changed from.
# TODO Also doesn't work for scimin minimization. It does that weird thing where
# multiple lines are drawn on the contour
#P = np.array([[1, 5],
# [2, 3],
# [3, 2],
# [4, 1]])
#
#ranks = [3,4,2,1]


#P = np.array([[4, 4],
# [4, 3],
# [2, 4],
# [4, 1],
# [1, 3]]);
#
#ranks = [1,2,3,4,5]


# Partial ordering example
P = np.array([[3.6, 3.9], [2.5, 4.1], [5.5, 2.5], [0.5, 5.2], [6.9, 1.8]])

ranks = [1, 2, 3, 3, 4]

# opt_method can be trust-constr, SLSQP, ES, or GA
opt_method = "trust-constr"

# linear or poly
fnc_type = "poly"


if fnc_type == "linear":

vf_res = mvf.create_linear_vf(P, ranks, method=opt_method)

elif fnc_type == "poly":

vf_res = mvf.create_poly_vf(P, ranks, method=opt_method)

else:

print("function not supported")

if vf_res.fit:

print("Final parameters:")
print(vf_res.params)

print("Final epsilon:")
print(vf_res.epsilon)

mvf.plot_vf(P, vf_res.vf)




Loading