var MALE_CLASS, IF_MALE;

if ((IS_SEX == ("\"one\"")) || (IS_SEX == ("\"two\""))) {
    if (JSON.parse(IS_SEX) != "one") {
        MALE_CLASS = NUM_CLASS;
        IF_MALE = 1;
    } else {
        MALE_CLASS = 0;
        IF_MALE = 0;
    }
} else {
    if (IS_SEX != "one") {
        MALE_CLASS = NUM_CLASS;
        IF_MALE = 1;
    } else {
        MALE_CLASS = 0;
        IF_MALE = 0;
    }
}

/*MALE_CLASS = (IS_SEX != "one") ? NUM_CLASS : 0;
var IF_MALE = (IS_SEX != "one") ? 1 : 0;*/

var NODE_ARRAY = [];
var CONNECT_ARRAY = [];
var CONNECT_ROW = [];
var CONNECT_COL = [];
var INIT_RETURN = [0];
var SIZE_INIT_RETURN;
var FEM_RATIO = 0.5;
var FEM_RATIO1 = 0.5;
var FEM_RATIO2 = 0.5;
var FEM_RATIO3 = 0.5;
var YDD_POP1 = 0;
var ODD_POP1 = 0;
var MMDD_POP1 = 0;
var YDD_POP2 = 0;
var ODD_POP2 = 0;
var MMDD_POP2 = 0;
var YDD_POP3 = 0;
var ODD_POP3 = 0;
var MMDD_POP3 = 0;

var MAX_ENVIR1 = 1;
var MAX_ENVIR2 = 0;
var MAX_ENVIR3 = 0;

var MINM_COHORT1 = 0;
var MAXM_COHORT1 = 0;
var MINF_COHORT1 = 0;
var MAXF_COHORT1 = 0;
var MINM_COHORT2 = 0;
var MAXM_COHORT2 = 0;
var MINF_COHORT2 = 0;
var MAXF_COHORT2 = 0;
var MINM_COHORT3 = 0;
var MAXM_COHORT3 = 0;
var MINF_COHORT3 = 0;
var MAXF_COHORT3 = 0;

MAXF_COHORT1 = (NUM_CLASS - 1);

if (IS_SEX !== "one") {
    MAXM_COHORT1 = (NUM_CLASS - 1);
} else {
    MAXM_COHORT1 = 0;
}

YDD_POP1 = ALL_DD_VALUES[0][0];
ODD_POP1 = ALL_DD_VALUES[0][1];
MMDD_POP1 = ALL_DD_VALUES[0][2];

if (NUM_NODES >= 2) {
    YDD_POP2 = ALL_DD_VALUES[1][0];
    ODD_POP2 = ALL_DD_VALUES[1][1];
    MMDD_POP2 = ALL_DD_VALUES[1][2];
    MAX_ENVIR2 = 1;

    MAXF_COHORT2 = (NUM_CLASS - 1);
    if (IS_SEX !== "one") {
        MAXM_COHORT2 = (NUM_CLASS - 1);
    } else {
        MAXM_COHORT2 = 0;
    }

    if (NUM_NODES == 3) {
        YDD_POP3 = ALL_DD_VALUES[2][0];
        ODD_POP3 = ALL_DD_VALUES[2][1];
        MMDD_POP3 = ALL_DD_VALUES[2][2];
        MAX_ENVIR3 = 1;

        MAXF_COHORT3 = (NUM_CLASS - 1);
        if (IS_SEX !== "one") {
            MAXM_COHORT3 = (NUM_CLASS - 1);
        } else {
            MAXM_COHORT3 = 0;
        }
    }
}

var MALE_RH_POP1 = 0;
var MALE_RH_POP2 = 0;
var MALE_RH_POP3 = 0;
var FEM_RH_POP1 = 0;
var FEM_RH_POP2 = 0;
var FEM_RH_POP3 = 0;

if (IS_SEX == "one") {
    FEM_RH_POP1 = ALL_RANDOM_H[0][0];
} else {
    MALE_RH_POP1 = ALL_RANDOM_H[0][0];
    FEM_RH_POP1 = ALL_RANDOM_H[0][3];
}

if (NUM_NODES >= 2) {

    if (IS_SEX == "one") {
        FEM_RH_POP2 = ALL_RANDOM_H[1][0];
    } else {
        MALE_RH_POP2 = ALL_RANDOM_H[1][0];
        FEM_RH_POP2 = ALL_RANDOM_H[1][3];
    }

    if (NUM_NODES == 3) {
        if (IS_SEX == "one") {
            FEM_RH_POP3 = ALL_RANDOM_H[2][0];
        } else {
            MALE_RH_POP3 = ALL_RANDOM_H[2][0];
            FEM_RH_POP3 = ALL_RANDOM_H[2][3];
        }
    }
}

var STOP_MALE;

if (IS_SEX == "one") {
    STOP_MALE = 0;
}

/*if (IS_SEX == "one") {
    DD_TYPES[2] = 0;
    FEM_RATIO = 1.0;
}*/

if ((IS_SEX == ("\"one\"")) || (IS_SEX == ("\"two\""))) {
    if (JSON.parse(IS_SEX) == "one") {
        DD_TYPES[2] = 0;
        FEM_RATIO = 1.0;
    }
} else {
    if (IS_SEX == "one") {
        DD_TYPES[2] = 0;
        FEM_RATIO = 1.0;
    }
}

if (NUM_NODES == 2) {

    NODE_ARRAY = [0, 1];
    CONNECT_ARRAY.push([NODE_CONNECT[0], NODE_CONNECT[1]]);
    CONNECT_ARRAY.push([NODE_CONNECT[2], NODE_CONNECT[3]]);
    CONNECT_ROW = ["0", "1"];
    CONNECT_COL = [" ", "0", "1"];
    INIT_RETURN = [0, 0];

} else if (NUM_NODES == 3) {

    NODE_ARRAY = [0, 1, 2];
    CONNECT_ARRAY.push([NODE_CONNECT[0], NODE_CONNECT[1], NODE_CONNECT[2]]);
    CONNECT_ARRAY.push([NODE_CONNECT[3], NODE_CONNECT[4], NODE_CONNECT[5]]);
    CONNECT_ARRAY.push([NODE_CONNECT[6], NODE_CONNECT[7], NODE_CONNECT[8]]);
    CONNECT_ROW = ["0", "1", "2"];
    CONNECT_COL = [" ", "0", "1", "2"];
    INIT_RETURN = [0, 0, 0];

} else {

    NODE_ARRAY = [0];
    CONNECT_ARRAY.push([1.0]);
    CONNECT_ROW = ["0"];
    CONNECT_COL = [" ", "0"];
}

/*var Ball = 0;

for (var i = 0; i < NUM_CLASS; i++) {

    if (SEX_CHECK != "one") {
        Ball += (ALL_MALE_WEIGHTS[this.Super.id][i] * XM[i]);
    }
    Ball += (ALL_FEM_WEIGHTS[this.Super.id][i] * XF[i]);
}*/

var INIT_TOTAL_SIZE;
var INIT_TOTAL_BIO;

if (NUM_NODES == 2) {

    INIT_TOTAL_SIZE = [0, 0];
    INIT_TOTAL_BIO = [0, 0];
    if (IS_SEX !== "one") {
        for (var i = 0; i < NUM_CLASS; i++) {
            INIT_TOTAL_SIZE[0] += ALL_M_CLASS[0][i];
            INIT_TOTAL_SIZE[0] += ALL_F_CLASS[0][i];
            INIT_TOTAL_SIZE[1] += ALL_M_CLASS[1][i];
            INIT_TOTAL_SIZE[1] += ALL_F_CLASS[1][i];

            INIT_TOTAL_BIO[0] += ALL_M_CLASS[0][i] * ALL_MALE_WEIGHTS[0][i];
            INIT_TOTAL_BIO[0] += ALL_F_CLASS[0][i] * ALL_FEM_WEIGHTS[0][i];
            INIT_TOTAL_BIO[1] += ALL_M_CLASS[1][i] * ALL_MALE_WEIGHTS[1][i];
            INIT_TOTAL_BIO[1] += ALL_F_CLASS[1][i] * ALL_FEM_WEIGHTS[1][i];
        }
    } else {
        for (var i = 0; i < NUM_CLASS; i++) {
            INIT_TOTAL_SIZE[0] += ALL_F_CLASS[0][i];
            INIT_TOTAL_SIZE[1] += ALL_F_CLASS[1][i];

            INIT_TOTAL_BIO[0] += ALL_F_CLASS[0][i] * ALL_FEM_WEIGHTS[0][i];
            INIT_TOTAL_BIO[1] += ALL_F_CLASS[1][i] * ALL_FEM_WEIGHTS[1][i];
        }
    }

} else if (NUM_NODES == 3) {

    INIT_TOTAL_SIZE = [0, 0, 0];
    INIT_TOTAL_BIO = [0, 0, 0];
    if (IS_SEX !== "one") {
        for (var i = 0; i < NUM_CLASS; i++) {
            INIT_TOTAL_SIZE[0] += ALL_M_CLASS[0][i];
            INIT_TOTAL_SIZE[0] += ALL_F_CLASS[0][i];
            INIT_TOTAL_SIZE[1] += ALL_M_CLASS[1][i];
            INIT_TOTAL_SIZE[1] += ALL_F_CLASS[1][i];
            INIT_TOTAL_SIZE[2] += ALL_M_CLASS[2][i];
            INIT_TOTAL_SIZE[2] += ALL_F_CLASS[2][i];

            INIT_TOTAL_BIO[0] += ALL_M_CLASS[0][i] * ALL_MALE_WEIGHTS[0][i];
            INIT_TOTAL_BIO[0] += ALL_F_CLASS[0][i] * ALL_FEM_WEIGHTS[0][i];
            INIT_TOTAL_BIO[1] += ALL_M_CLASS[1][i] * ALL_MALE_WEIGHTS[1][i];
            INIT_TOTAL_BIO[1] += ALL_F_CLASS[1][i] * ALL_FEM_WEIGHTS[1][i];
            INIT_TOTAL_BIO[2] += ALL_M_CLASS[2][i] * ALL_MALE_WEIGHTS[2][i];
            INIT_TOTAL_BIO[2] += ALL_F_CLASS[2][i] * ALL_FEM_WEIGHTS[2][i];
        }
    } else {
        for (var i = 0; i < NUM_CLASS; i++) {
            INIT_TOTAL_SIZE[0] += ALL_F_CLASS[0][i];
            INIT_TOTAL_SIZE[1] += ALL_F_CLASS[1][i];
            INIT_TOTAL_SIZE[2] += ALL_F_CLASS[2][i];

            INIT_TOTAL_BIO[0] += ALL_F_CLASS[0][i] * ALL_FEM_WEIGHTS[0][i];
            INIT_TOTAL_BIO[1] += ALL_F_CLASS[1][i] * ALL_FEM_WEIGHTS[1][i];
            INIT_TOTAL_BIO[2] += ALL_F_CLASS[2][i] * ALL_FEM_WEIGHTS[2][i];
        }
    }

} else {

    INIT_TOTAL_SIZE = [0];
    INIT_TOTAL_BIO = [0];
    if (IS_SEX !== "one") {
        for (var i = 0; i < NUM_CLASS; i++) {
            INIT_TOTAL_SIZE[0] += ALL_M_CLASS[0][i];
            INIT_TOTAL_SIZE[0] += ALL_F_CLASS[0][i];

            INIT_TOTAL_BIO[0] += ALL_M_CLASS[0][i] * ALL_MALE_WEIGHTS[0][i];
            INIT_TOTAL_BIO[0] += ALL_F_CLASS[0][i] * ALL_FEM_WEIGHTS[0][i];
        }
    } else {
        for (var i = 0; i < NUM_CLASS; i++) {
            INIT_TOTAL_SIZE[0] += ALL_F_CLASS[0][i];
            INIT_TOTAL_BIO[0] += ALL_F_CLASS[0][i] * ALL_FEM_WEIGHTS[0][i];
        }
    }
}

Novaol.recordJSON({
    title: "metaPVA",
    address: "omuellerklein@berkeley.edu",
    date: "2016",
    /*clock: {
        lo: 0,
        hi: 200,
        max: 2000,
        dt: 1.000000,
        method: "Euler",
        step: 1
    },*/
    clock: {
        lo: 0,
        hi: 200,
        max: 2000,
        dt: 1.000000,
        method: "Euler",
        step: 1
    },
    modcontrols: [
        [{
            type: "slider",
            id: "fPseudo",
            text: "Adult Female Pseudo-Extinction",
            size: 6,
            min: 0,
            max: 10,
            value: 0,
            step: 1
        }, {
            type: "slider",
            id: "mPseudo",
            text: "Adult Male Pseudo-Extinction",
            size: 6,
            min: 0,
            max: (IS_SEX == "one") ? STOP_MALE : 10,
            value: 0,
            step: 1
        }, {
            type: "slider",
            id: "FSexRatio",
            text: "Ratio of Females",
            size: 6,
            min: 0.00,
            max: 1.00,
            value: FEM_RATIO,
            step: 0.01
        }],
        [{
            type: "switch",
            id: "dStoch",
            text: "Demographic Stochasticity",
            left: "Off",
            right: "On",
            checked: (STOCH_TYPES[0] == 1) ? true : false,
            /*initChecked: (STOCH_TYPES[0] == 1) ? true : false,*/
            value: STOCH_TYPES[0]
        }, {
            type: "switch",
            id: "isTrans",
            text: "Engage Metapopulation Migration",
            left: "Off",
            right: "On",
            checked: false,
            value: 0
        }, {
            type: "switch",
            id: "rFitness",
            text: "Migration with Relative Fitness",
            left: "Off",
            right: "On",
            checked: false,
            value: 0
        }],
        [{
            type: "slider",
            id: "gammaEnvir1",
            text: "Env. Stochasticity of Pop1",
            size: 6,
            min: 0,
            max: MAX_ENVIR1,
            value: 0,
            step: 0.1
        }, {
            type: "slider",
            id: "gammaEnvir2",
            text: "Env. Stochasticity for Pop2",
            size: 6,
            min: 0,
            max: MAX_ENVIR2,
            value: 0,
            step: 0.1
        }, {
            type: "slider",
            id: "gammaEnvir3",
            text: "Env. Stochasticity for Pop3",
            size: 6,
            min: 0,
            max: MAX_ENVIR3,
            value: 0,
            step: 0.1
        }],
        [{
            type: "field",
            id: "yDD1",
            text: "Young DD Param of Pop1",
            size: 10,
            value: YDD_POP1,
            readonly: false
        }, {
            type: "field",
            id: "oDD1",
            text: "Old DD Param of Pop1",
            size: 10,
            value: ODD_POP1,
            readonly: false
        }, {
            type: "field",
            id: "mmDD1",
            text: "Mature-Male DD Param of Pop1",
            size: 10,
            value: MMDD_POP1,
            readonly: false
        }],
        [{
            type: "field",
            id: "yDD2",
            text: "Young DD Param of Pop2",
            size: 10,
            value: YDD_POP2,
            readonly: false
        }, {
            type: "field",
            id: "oDD2",
            text: "Old DD Param of Pop2",
            size: 10,
            value: ODD_POP2,
            readonly: false
        }, {
            type: "field",
            id: "mmDD2",
            text: "Mature-Male DD Param of Pop2",
            size: 10,
            value: MMDD_POP2,
            readonly: false
        }],
        [{
            type: "field",
            id: "yDD3",
            text: "Young DD Param of Pop3",
            size: 10,
            value: YDD_POP3,
            readonly: false
        }, {
            type: "field",
            id: "oDD3",
            text: "Old DD Param of Pop3",
            size: 10,
            value: ODD_POP3,
            readonly: false
        }, {
            type: "field",
            id: "mmDD3",
            text: "Mature-Male DD Param of Pop3",
            size: 10,
            value: MMDD_POP3,
            readonly: false
        }],
        [{
            type: "field",
            id: "rHarvest1",
            text: "Male Random Harvest Amount Pop1",
            size: 10,
            value: MALE_RH_POP1,
            readonly: false
        }, {
            type: "field",
            id: "rHarvest2",
            text: "Male Random Harvest Amount Pop2",
            size: 10,
            value: MALE_RH_POP2,
            readonly: false
        }, {
            type: "field",
            id: "rHarvest3",
            text: "Male Random Harvest Amount Pop3",
            size: 10,
            value: MALE_RH_POP3,
            readonly: false
        }],
        [{
            type: "field",
            id: "rFHarvest1",
            text: "Female Random Harvest Amount Pop1",
            size: 10,
            value: FEM_RH_POP1,
            readonly: false
        }, {
            type: "field",
            id: "rFHarvest2",
            text: "Female Random Harvest Amount Pop2",
            size: 10,
            value: FEM_RH_POP2,
            readonly: false
        }, {
            type: "field",
            id: "rFHarvest3",
            text: "Female Random Harvest Amount Pop3",
            size: 10,
            value: FEM_RH_POP3,
            readonly: false
        }],
        [{
            type: "slider",
            id: "minmCohort1",
            text: "Min Male Cohort1",
            size: 6,
            min: 0,
            max: 10,
            value: 1,
            step: 1
        }, {
            type: "slider",
            id: "minmCohort2",
            text: "Min Male Cohort2",
            size: 6,
            min: 0,
            max: 10,
            value: 1,
            step: 1
        }, {
            type: "slider",
            id: "minmCohort3",
            text: "Min Male Cohort3",
            size: 6,
            min: 0,
            max: 10,
            value: 1,
            step: 1
        }],
        [{
            type: "slider",
            id: "FSexRatio1",
            text: "Ratio of Females1",
            size: 6,
            min: 0.00,
            max: 1.00,
            value: FEM_RATIO1,
            step: 0.01
        }, {
            type: "slider",
            id: "FSexRatio2",
            text: "Ratio of Females2",
            size: 6,
            min: 0.00,
            max: 1.00,
            value: FEM_RATIO2,
            step: 0.01
        }, {
            type: "slider",
            id: "FSexRatio3",
            text: "Ratio of Females3",
            size: 6,
            min: 0.00,
            max: 1.00,
            value: FEM_RATIO3,
            step: 0.01
        },
        /*],[
        {type: "slider", id: "selectFems", text: "# Females Harvesting", size: 6, min: 0, max: 100, value: 0, step: 1},
        {type: "slider", id: "selectMales", text: "# Males Harvesting", size: 6, min: 0, max: 100, value: 0, step: 1},
        {type: "slider", id: "selectYoung", text: "# Young Harvesting", size: 6, min: 0, max: 10, value: 0, step: 1},
        {type: "slider", id: "randomHarv", text: "Interval Random Harvesting", size: 6, min: 0, max: 100, value: ALL_RANDOM_H[0], step: 1}
        ],[
        {type: "slider", id: "selectFems", text: "# Females Harvesting", size: 6, min: 0, max: 100, value: 0, step: 1},
        {type: "slider", id: "selectMales", text: "# Males Harvesting", size: 6, min: 0, max: 100, value: 0, step: 1},
        {type: "slider", id: "selectYoung", text: "# Young Harvesting", size: 6, min: 0, max: 10, value: 0, step: 1},
        {type: "slider", id: "randomHarv", text: "Interval Random Harvesting", size: 6, min: 0, max: 100, value: ALL_RANDOM_H[0], step: 1}*/
    ], [{
            type: "switch",
            id: "isDD1",
            text: "Include Density Dependence of Young",
            left: "Off",
            right: "On",
            checked: (DD_TYPES[0] == 1) ? true : false,
            value: DD_TYPES[0]
        }, {
            type: "switch",
            id: "isDD2",
            text: "Include Density Dependence of Old",
            left: "Off",
            right: "On",
            checked: (DD_TYPES[1] == 1) ? true : false,
            value: DD_TYPES[1]
        }, {
            type: "switch",
            id: "isDD3",
            text: "Include Density Dependence of Mature-Male",
            left: "Off",
            right: "On",
            checked: (DD_TYPES[2] == 1) ? true : false,
            value: DD_TYPES[2]
        }
    ],
    ],
    visuals: function(hook, project, index) {

        var table = hook.append("table").attr("class", "dataTable");
        var row = table.append('tr');

        if (NUM_NODES !== 1) {
            row.append('td')
                .style('vertical-align', 'top')
                .style('display', 'table')
                .style('padding', '15px')
                .append("div")
                .attr("id", "Connectance_" + project + "_" + index)
                .attr('class', 'PL_Tableau');

        }

        var sexCheck = "one";
        if ((IS_SEX == ("\"one\"")) || (IS_SEX == ("\"two\""))) {
            if (JSON.parse(IS_SEX) != "one") {
                sexCheck = "two";
            }
        } else {
            if (IS_SEX != "one") {
                sexCheck = "two";
            }
        }
        /*if (IS_SEX != "one") {*/
        if (sexCheck != "one") {
            //var row1 = table.append('tr');
            var row1 = row.append('td').append('table').append('tr');
            //row1.selectAll('td').data([0,1,2])
            row1.selectAll('td').data(NODE_ARRAY)
                .enter().append('td').attr('id', 'maleAttr')
                .style('padding', '15px')
                .append("div")
                .attr("id", function(d) {
                    return "malePop_" + project + "_" + index + "_" + d;
                })
                .attr('class', 'PL_Cascade');

            var row2 = row1.append('td').append('table').append('tr');

        } else {

            var row2 = row.append('td').append('table').append('tr');

        }

        //var row2 = row1.append('td').append('table').append('tr');
        //var row = table.append('tr');
        //row2.selectAll('td').data([0,1,2])
        row2.selectAll('td').data(NODE_ARRAY)
            .enter().append('td').attr('id', 'femAttr')
            .style('padding', '15px')
            .append("div")
            .attr("id", function(d) {
                return "femPop_" + project + "_" + index + "_" + d;
            })
            .attr('class', 'PL_Cascade');

        var row = table.append('tr');
        row.append('td')
            .style('vertical-align', 'top')
            .style('padding', '5px')
            .append("div")
            .attr("id", "BioPlot_" + project + "_" + index)
            .attr('class', 'linechart')

        //var row = table.append('tr');
        row.append('td')
            .style('vertical-align', 'top')
            .style('padding', '5px')
            .append("div")
            .attr("id", "PopSize_" + project + "_" + index)
            .attr('class', 'linechart')

        var row = table.append('tr');
        row.append('td')
            .style('vertical-align', 'top')
            .style('padding', '5px')
            .append("div")
            .attr("id", "TransPlot_" + project + "_" + index)
            .attr('class', 'barchart')
            //.attr('class', 'linechart')

        //var row = table.append('tr');
        row.append('td')
            .style('vertical-align', 'top')
            .style('padding', '5px')
            .append("div")
            .attr("id", "DepartPlot_" + project + "_" + index)
            .attr('class', 'barchart')
            //.attr('class', 'linechart')

        var row = table.append('tr');
        row.append('td')
            .style('vertical-align', 'top')
            .style('display', 'table')
            .style('padding', '15px')
            .append("div")
            .attr("id", "DepartData_" + project + "_" + index)
            .attr('class', 'table')
    },
    params: function(project, index) {
        return {
            BioPlot: {
                vizid: "BioPlot_" + project + "_" + index,
                width: 520,
                height: 300,
                padding: {
                    top: 0,
                    right: 0,
                    bottom: 0,
                    left: 25,
                },
                margin: {
                    top: 40,
                    right: 20,
                    bottom: 40,
                    left: 60
                },
                autogen: true,
                valueFunc: function(data) {
                    return data.val;
                },
                textFunc: function(data) {
                    return data.time;
                },
                lo: novaol.get("clock.lo"),
                hi: globl[project].controls[index].simhi,
                caption: "Biomass per region",
                streams: NUM_NODES,
                strokes: ["#0000ff", "#ff0000", "#b2497d"],
                init: function() {
                    /* return INIT_RETURN; */
                    return INIT_TOTAL_BIO;
                },
            },
            PopSize: {
                vizid: "PopSize_" + project + "_" + index,
                width: 520,
                height: 300,
                padding: {
                    top: 0,
                    right: 0,
                    bottom: 0,
                    left: 25,
                },
                margin: {
                    top: 40,
                    right: 20,
                    bottom: 40,
                    left: 60
                },
                autogen: true,
                valueFunc: function(data) {
                    return data.val;
                },
                textFunc: function(data) {
                    return data.time;
                },
                lo: novaol.get("clock.lo"),
                hi: globl[project].controls[index].simhi,
                caption: "Population size per region",
                streams: NUM_NODES,
                strokes: ["#0000ff", "#ff0000", "#b2497d"],
                init: function() {
                    /* return INIT_RETURN; */
                    return INIT_TOTAL_SIZE;
                },
            },
            /*TransPlot: {
                vizid: "TransPlot_"+project+"_"+index,
                width: 500,
                height: 350,
                margin: {top: 40, right: 20, bottom: 40, left: 60},
                caption: "Net transitions of each subpopultion",
                colors: ["#0000ff", "#ff0000", "#b2497d"],
            },
            DepartPlot: {
                vizid: "DepartPlot_"+project+"_"+index,
                width: 500,
                height: 350,
                margin: {top: 40, right: 20, bottom: 40, left: 60},
                caption: "Net departures of each subpopulation",
                colors: ["#0000ff", "#ff0000", "#b2497d"],
            },*/
            TransPlot: {
                vizid: "TransPlot_" + project + "_" + index,
                width: 520,
                height: 300,
                margin: {
                    top: 40,
                    right: 20,
                    bottom: 40,
                    left: 60
                },
                autogen: true,
                valueFunc: function(data) {
                    return data.val;
                },
                textFunc: function(data) {
                    return data.time;
                },
                lo: novaol.get("clock.lo"),
                hi: globl[project].controls[index].simhi,
                caption: "Net migrations per region",
                streams: NUM_NODES,
                strokes: ["#0000ff", "#ff0000", "#b2497d"],
                init: function() {
                    return INIT_RETURN
                },
            },
            DepartPlot: {
                vizid: "DepartPlot_" + project + "_" + index,
                width: 520,
                height: 300,
                margin: {
                    top: 40,
                    right: 20,
                    bottom: 40,
                    left: 60
                },
                autogen: true,
                valueFunc: function(data) {
                    return data.val;
                },
                textFunc: function(data) {
                    return data.time;
                },
                lo: novaol.get("clock.lo"),
                hi: globl[project].controls[index].simhi,
                caption: "Total harvesting per region",
                streams: NUM_NODES,
                strokes: ["#0000ff", "#ff0000", "#b2497d"],
                init: function() {
                    return INIT_RETURN
                },
            },
            DepartData: {
                vizid: "DepartData_" + project + "_" + index,
                width: 1000,
                height: 500,
                autogen: true,
                caption: "Depart data per pop",
                columns: ["Time", "Pop1_Size", "Pop1_Males", "Pop1_Females",
                    "Pop1_Biomass", "Pop2_Size", "Pop2_Males", "Pop2_Females",
                    "Pop2_Biomass", "Pop3_Size", "Pop3_Males", "Pop3_Females",
                    "Pop3_Biomass"
                ],
                /*columns: ["Time", "Pop1_Size", "Pop1_Males", "Pop1_Females", "Pop1_Biomass", "Pop1_Depart", "Pop1_Trans"],*/
                valueFuncs: [
                    function(d) {
                        return d.time;
                    },
                    function(d) {
                        return d.csvSize1;
                    },
                    function(d) {
                        return d.csvMSize1;
                    },
                    function(d) {
                        return d.csvFSize1;
                    },
                    function(d) {
                        return d.csvBio1;
                    },
                    function(d) {
                        return d.csvSize2;
                    },
                    function(d) {
                        return d.csvMSize2;
                    },
                    function(d) {
                        return d.csvFSize2;
                    },
                    function(d) {
                        return d.csvBio2;
                    },
                    function(d) {
                        return d.csvSize3;
                    },
                    function(d) {
                        return d.csvMSize3;
                    },
                    function(d) {
                        return d.csvFSize3;
                    },
                    function(d) {
                        return d.csvBio3;
                    }
                ],
                keys: [
                    "time",
                    "csvSize1",
                    "csvMSize1",
                    "csvFSize1",
                    "csvBio1",
                    "csvSize2",
                    "csvMSize2",
                    "csvFSize2",
                    "csvBio2",
                    "csvSize3",
                    "csvMSize3",
                    "csvFSize3",
                    "csvBio3"
                ],
                init: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            },
            Connectance: {
                vizid: "Connectance_" + project + "_" + index,
                /*rowHeaders: ["0", "1", "2"],
                columnLabels: [" ", "0", "1", "2"],*/
                rowHeaders: CONNECT_ROW,
                columnLabels: CONNECT_COL,
                width: 200,
                height: 150,
                rows: NUM_NODES,
                cols: NUM_NODES,
                caption: "Node to node connectance",
                margin: {
                    top: 40,
                    right: 40,
                    bottom: 50,
                    left: 70
                },
                /*initial: [[0.8, 0.2, 0.0],
                          [0.2, 0.6, 0.2],
                          [0.0, 0.2, 0.6]],*/
                initial: CONNECT_ARRAY
            },
            malePop: {
                vizid: "malePop_" + project + "_" + index,
                vizid_subscript: true,
                count: MALE_CLASS,
                columns: IF_MALE,
                dsize: 6,
                caption: "Male    age-classes ",
                background: "pink"
            },
            femPop: {
                vizid: "femPop_" + project + "_" + index,
                vizid_subscript: true,
                count: NUM_CLASS,
                columns: 1,
                dsize: 6,
                caption: "Female age-classes ",
                background: "blue"
            },
        }
    }
});
