# Path: platypus/problems.py
# class DTLZ2(Problem):
#     
#     def __init__(self, nobjs = 2, nvars=None):
#         super(DTLZ2, self).__init__(nobjs+9 if nvars is None else nvars, nobjs)
#         self.types[:] = Real(0, 1)
#         
#     def evaluate(self, solution):
#         k = self.nvars - self.nobjs + 1
#         g = sum([math.pow(x - 0.5, 2.0) for x in solution.variables[self.nvars-k:]])
#         f = [1.0+g]*self.nobjs
# 
#         for i in range(self.nobjs):
#             f[i] *= functools.reduce(operator.mul,
#                            [math.cos(0.5 * math.pi * x) for x in solution.variables[:self.nobjs-i-1]],
#                            1)
#             
#             if i > 0:
#                 f[i] *= math.sin(0.5 * math.pi * solution.variables[self.nobjs-i-1])
#         
#         solution.objectives[:] = f
#         
#     def random(self):
#         solution = Solution(self)
#         solution.variables[:self.nobjs-1] = [random.uniform(0.0, 1.0) for _ in range(self.nobjs-1)]
#         solution.variables[self.nobjs-1:] = 0.5
#         solution.evaluate()
#         return solution


import pickle
import unittest
import functools
from ..problems import DTLZ2
from ..algorithms import *
from ..weights import *
        pickle.dumps(CMAES(self.problem))
        
    def test_GDE3(self):
        pickle.dumps(GDE3(self.problem))
        
    def test_IBEA(self):
        pickle.dumps(IBEA(self.problem))

    def test_MOEAD_random_weights(self):
        pickle.dumps(MOEAD(self.problem))

    def test_MOEAD_normal_boundary_weights(self):
        pickle.dumps(MOEAD(self.problem, weight_generator=normal_boundary_weights, divisions_outer=24))
        
    def test_OMOPSO(self):
        pickle.dumps(OMOPSO(self.problem, epsilons=[0.01]))
        
    def test_SMPSO(self):
        pickle.dumps(SMPSO(self.problem))
        
    def test_SPEA2(self):
        pickle.dumps(SPEA2(self.problem))
        
    def test_EpsMOEA(self):
        pickle.dumps(EpsMOEA(self.problem, epsilons=[0.01]))


class TestRunning(unittest.TestCase):
    
    def setUp(self):

# Path: platypus/problems.py
# class DTLZ2(Problem):
#     
#     def __init__(self, nobjs = 2, nvars=None):
#         super(DTLZ2, self).__init__(nobjs+9 if nvars is None else nvars, nobjs)
#         self.types[:] = Real(0, 1)
#         
#     def evaluate(self, solution):
#         k = self.nvars - self.nobjs + 1
#         g = sum([math.pow(x - 0.5, 2.0) for x in solution.variables[self.nvars-k:]])
#         f = [1.0+g]*self.nobjs
# 
#         for i in range(self.nobjs):
#             f[i] *= functools.reduce(operator.mul,
#                            [math.cos(0.5 * math.pi * x) for x in solution.variables[:self.nobjs-i-1]],
#                            1)
#             
#             if i > 0:
#                 f[i] *= math.sin(0.5 * math.pi * solution.variables[self.nobjs-i-1])
#         
#         solution.objectives[:] = f
#         
#     def random(self):
#         solution = Solution(self)
#         solution.variables[:self.nobjs-1] = [random.uniform(0.0, 1.0) for _ in range(self.nobjs-1)]
#         solution.variables[self.nobjs-1:] = 0.5
#         solution.evaluate()
#         return solution


# Path: platypus/tests/test_algorithms.py
import pickle
import unittest
import functools
from ..problems import DTLZ2
from ..algorithms import *
from ..weights import *

        pickle.dumps(CMAES(self.problem))
        
    def test_GDE3(self):
        pickle.dumps(GDE3(self.problem))
        
    def test_IBEA(self):
        pickle.dumps(IBEA(self.problem))

    def test_MOEAD_random_weights(self):
        pickle.dumps(MOEAD(self.problem))

    def test_MOEAD_normal_boundary_weights(self):
        pickle.dumps(MOEAD(self.problem, weight_generator=normal_boundary_weights, divisions_outer=24))
        
    def test_OMOPSO(self):
        pickle.dumps(OMOPSO(self.problem, epsilons=[0.01]))
        
    def test_SMPSO(self):
        pickle.dumps(SMPSO(self.problem))
        
    def test_SPEA2(self):
        pickle.dumps(SPEA2(self.problem))
        
    def test_EpsMOEA(self):
        pickle.dumps(EpsMOEA(self.problem, epsilons=[0.01]))


class TestRunning(unittest.TestCase):
    
    def setUp(self):

        self.problem = DTLZ2()