#!/usr/bin/env python
from waflib.Configure import conf
import sferes

def build(bld):
    uselib_ = 'TBB BOOST EIGEN PTHREAD GSL MPI BULLET OGLFT FREETYPE OPENGL GLUT PNGWRITER'
    cxxflags_kdtree = bld.get_env()['CXXFLAGS', '-I.', '-DLIBSSRCKDTREE_HAVE_BOOST']

    lzw = bld.stlib(features = 'cxx cxxstlib',
                    source = 'lzw.cpp',
                    includes = '. ../../',
                    target = 'lzw',
                    uselib = uselib_)

    # Generic robot experiment with visualization
    if(False):
        sferes.create_variants(bld,
        source = 'mod_robot.cpp',
        use = 'sferes2 lzw OpenGLSupport oglft',
        uselib = uselib_,
        target = 'robot',
        cxxflags = cxxflags_kdtree,
        variants = ['DBG MRV1 MRS1 POP12 GEN10 BIN10 PMOD GMOD NOMPI VISUALIZE'])
    
    # The same robot experiments without visualization and without OpenGL support
    if(False):
        sferes.create_variants(bld,
        source = 'mod_robot.cpp',
        use = 'sferes2 lzw OpenGLSupport oglft',
        uselib = uselib_,
        target = 'robot',
        cxxflags = cxxflags_kdtree,
        variants = ['MRV1 MRS1 POP12 GEN10 BIN10 PMOD GMOD NOMPI NOGL'])
    
    # Experiment for testing MPCMOEA on a small problem
    if(False):
        sferes.create_variants(bld,
        source = 'mod_robot.cpp',
        use = 'sferes2 lzw OpenGLSupport oglft',
        uselib = uselib_,
        target = 'robot',
        cxxflags = cxxflags_kdtree,
        variants = ['DBG MRV1 MRS6 POP2 GEN10 BIN4 NOGL'])
    
    # Experiment for testing MPCMOEA release version on the six-tasks problem
    if(False):
        sferes.create_variants(bld,
        source = 'mod_robot.cpp',
        use = 'sferes2 lzw OpenGLSupport oglft',
        uselib = uselib_,
        target = 'robot',
        cxxflags = cxxflags_kdtree,
        variants = ['RLS MRV1 MRS5 POP2 GEN10 BIN4 NOGL'])
    
    # Debug settings for a neural network with multiple layers
    if(False):
        sferes.create_variants(bld,
        source = 'mod_robot.cpp',
        use = 'sferes2 lzw OpenGLSupport oglft',
        uselib = uselib_,
        target = 'robot',
        cxxflags = cxxflags_kdtree,
        variants = ['DBG MRV1 MRS6 SEVENTASKS MPCMOEA POP2 GEN10 BIN4 LAY2 VISUALIZE'])

    # Debug settings for a neural network with multiple layers
    if(False):
        sferes.create_variants(bld,
        source = 'mod_robot.cpp',
        use = 'sferes2 lzw OpenGLSupport oglft',
        uselib = uselib_,
        target = 'robot',
        cxxflags = cxxflags_kdtree,
        variants = ['RLS MRV2 MRS6 SEVENTASKS MPCMOEA POP2 GEN10 BIN4 LAY2 NOGL STEP5 TRIAL1'])
    
    # Settings for an experiment with the RETINA poison-food task with visualizations
    if(False):
        sferes.create_variants(bld,
        source = 'mod_robot.cpp',
        use = 'sferes2 lzw OpenGLSupport oglft',
        uselib = uselib_,
        target = 'robot',
        cxxflags = cxxflags_kdtree,
        variants = ['DBG MRV2 MRS6 RETINA MPCMOEA POP2 GEN10 BIN4 LAY2 VISUALIZE'])

    # Settings for an experiment with the RETINA poison-food task without visualizations
    if(False):
        sferes.create_variants(bld,
        source = 'mod_robot.cpp',
        use = 'sferes2 lzw OpenGLSupport oglft',
        uselib = uselib_,
        target = 'robot',
        cxxflags = cxxflags_kdtree,
        variants = ['DBG MRV2 MRS6 RETINA MPCMOEA POP2 GEN10 BIN4 LAY2 NOGL'])

    # Settings for the improved NSGA-II experiments
    if(False):
        sferes.create_variants(bld,
        source = 'mod_robot.cpp',
        use = 'sferes2 lzw OpenGLSupport oglft',
        uselib = uselib_,
        target = 'robot',
        cxxflags = cxxflags_kdtree,
        variants = ['RLS GEN10 POP4 MRV1 MRS2 NPAT NPCO DIVMINAVG NOMPI'])

    # Settings for the predator-prey experiment in a new coat
    if(False):
        sferes.create_variants(bld,
        source = 'mod_robot.cpp',
        use = 'sferes2 lzw OpenGLSupport oglft',
        uselib = uselib_,
        target = 'robot',
        cxxflags = cxxflags_kdtree,
        variants = ['DBG MRV2 MRS7 POP2 GEN10 BIN2 LAY2 VISUALIZE', 
                'DBG MRV2 MRS7 POP4 GEN10 BIN100 LAY2 NOGL TRIALS0 NOMETRICS NONETWORK',
                'RLS MRV2 MRS7 POP4 GEN10 BIN10 LAY2 NOGL',
                'DBG MRV2 MRS7 POP2 GEN10 BIN2 LAY2 NOGL GMOD PMOD TRIALS0'
                ])

    # Settings for loading fight-flight Oakridge results
    if(False):
        sferes.create_variants(bld,
        source = 'mod_robot.cpp',
        use = 'sferes2 lzw OpenGLSupport oglft',
        uselib = uselib_,
        target = 'robot',
        cxxflags = cxxflags_kdtree,
        variants = ['RLS MRV2 MRS7 POP4 GEN1000 BIN100 LAY2 NOGL',
            'RLS MRV2 MRS7 POP4 GEN1000 BIN100 LAY2 VISUALIZE PNGW',
            'RLS MRV2 MRS7 POP4 GEN1000 BIN100 LAY2 VISUALIZE PNGW RECORD'
                ])

    # Settings for loading 2016 CMOEA results
    if(True):
        sferes.create_variants(bld,
        source = 'mod_robot.cpp',
        use = 'sferes2 lzw OpenGLSupport oglft',
        uselib = uselib_,
        target = 'robot',
        cxxflags = cxxflags_kdtree,
        variants = ['DBG VISUALIZE GEN5000 POP1000 BIN100 MRV1 MRS1 NOMPI BULLET_2_81 PNGW RECORD',
                    'DBG VISUALIZE GEN5000 POP1000 BIN100 MRV1 MRS1 NOMPI BULLET_2_81 PNGW',
                    'DBG VISUALIZE GEN5000 NSGA POP6300 BIN100 MRV1 MRS2 NOMPI BULLET_2_81 PNGW RECORD',
                    'DBG VISUALIZE GEN5000 NSGA POP6300 BIN100 MRV1 MRS2 NOMPI BULLET_2_81 PNGW',
                    'DBG VISUALIZE GEN5000 LEXICASE POP6300 BIN100 MRV1 MRS2 NOMPI PNGW RECORD',
                    'DBG VISUALIZE GEN5000 LEXICASE POP6300 BIN100 MRV1 MRS2 NOMPI PNGW',
                    'DBG VISUALIZE GEN5000 NSGA POP6300 BIN100 MRV1 MRS3 NOMPI PNGW RECORD',
                    'DBG VISUALIZE GEN5000 NSGA POP6300 BIN100 MRV1 MRS3 NOMPI PNGW',
                    ])

    # Friction experiment
    if(False):
        sferes.create_variants(bld,
        source = 'mod_robot.cpp',
        use = 'sferes2 lzw OpenGLSupport oglft',
        uselib = uselib_,
        target = 'robot',
        cxxflags = cxxflags_kdtree,
        variants = ['RLS MRV2 MRS6 FORWARD POP100 GEN100 NOGL NOMPI FRICTION=2 STEP1000 NNPERIOD=10',
            'RLS MRV2 MRS6 FORWARD POP100 GEN100 VISUALIZE PNGW NOMPI FRICTION=2 STEP1000 NNPERIOD=10 RECORD EFFICIENCY',
            'DBG MRV2 MRS6 FORWARD POP100 GEN100 VISUALIZE NOMPI FRICTION=2 STEP1000 NNPERIOD=10 EFFICIENCY',
                ])

    # Settings for the lexicase experiment
    if(False):
        sferes.create_variants(bld,
        source = 'mod_robot.cpp',
        use = 'sferes2 lzw OpenGLSupport oglft',
        uselib = uselib_,
        target = 'robot',
        cxxflags = cxxflags_kdtree,
        variants = ['RLS LEXICASE GEN10 POP4 MRV1 MRS2 NPAT DIVMINAVG NOMPI NOGL'])


    # Settings for visualizing the neural network structure
    if(False):
        sferes.create_variants(bld,
        source = 'mod_robot.cpp',
        use = 'sferes2 lzw OpenGLSupport oglft',
        uselib = uselib_,
        target = 'robot',
        cxxflags = cxxflags_kdtree,
        variants = ['DBG RENDERNETWORK GEN5000 POP1000 BIN100 MRV1 HNN SIXTASKS MRMULT SIGH MAPELITEINOVPNSGA DIVMINAVG NOMPI CIRCLE NX5 NY6'])
