-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindicator.py
More file actions
39 lines (35 loc) · 1.26 KB
/
indicator.py
File metadata and controls
39 lines (35 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# -*- coding: utf-8 -*-
"""
indicator.py
Copyright (c) 2022 Nobuo Namura
This code is released under the MIT License.
"""
import numpy as np
from scipy.spatial import distance
from pymoo.indicators.hv import HV
#======================================================================
def rmse_history(x_rmse, problem, func, nfg=0):
rmse = 0.0
for x in x_rmse:
rmse += (problem(x)[nfg] - func(x))**2.0
rmse = np.sqrt(rmse/float(len(x_rmse[:,0])))
return rmse
#======================================================================
def igd_history(f, igd_ref, plus=False, MIN=[]):
if plus:
if len(MIN) == 0:
weight = np.full(len(f[0,:]), True)
weight = np.where(MIN, 1.0, -1.0)
dist = weight*(np.tile(f, [len(igd_ref[:,0]),1,1]).transpose([1,0,2]) - np.tile(igd_ref, [len(f[:,0]),1,1]))
dist = np.sqrt(np.sum(np.where(dist>0, dist, 0)**2, axis=2))
else:
dist = distance.cdist(f, igd_ref)
igd = np.mean(np.min(dist,axis=0))
return igd
#======================================================================
def hv_history(f, hv_ref, MIN=[]):
f_min = np.where(MIN, 1.0, -1.0)*f
ref_min = np.where(MIN, 1.0, -1.0)*hv_ref
hv = HV(ref_point=ref_min)
hv_min = hv(f_min)
return hv_min