diff --git a/modules/performUQ/dakota/dakotaProcedures.cpp b/modules/performUQ/dakota/dakotaProcedures.cpp index c295b2753..be7538025 100755 --- a/modules/performUQ/dakota/dakotaProcedures.cpp +++ b/modules/performUQ/dakota/dakotaProcedures.cpp @@ -11,37 +11,42 @@ #include "../common/parseWorkflowInput.h" int -writeRV(std::ostream &dakotaFile, struct randomVariables &theRandomVariables, std::string idVariables, std::vector &rvList, bool includeActiveText = true){ +writeRV(std::ostream &dakotaFile, struct randomVariables &theRandomVariables, std::string idVariables, std::vector &rvList, bool includeActiveText = true) { + dakotaFile << "variables \n "; // sy - because 'discrete_state_set' was coming before 'variables', when changing one variable to a constant in quoFEM example - int numContinuousDesign = theRandomVariables.continuousDesignRVs.size(); + int numContinuousDesign = theRandomVariables.continuousDesignRVs.size(); - if (numContinuousDesign != 0) { + std::cout << "numContinuousDesign" << std::endl; + std::cout << numContinuousDesign << std::endl; - if (idVariables.empty()) - dakotaFile << "variables \n "; - else - dakotaFile << "variables \n id_variables = '" << idVariables << "'\n"; - - if (numContinuousDesign > 0) { - dakotaFile << " continuous_design = " << numContinuousDesign << "\n initial_point = "; - // std::list::iterator it; - for (auto it = theRandomVariables.continuousDesignRVs.begin(); it != theRandomVariables.continuousDesignRVs.end(); it++) - dakotaFile << it->initialPoint << " "; - dakotaFile << "\n lower_bounds = "; - for (auto it = theRandomVariables.continuousDesignRVs.begin(); it != theRandomVariables.continuousDesignRVs.end(); it++) - dakotaFile << it->lowerBound << " "; - dakotaFile << "\n upper_bounds = "; - for (auto it = theRandomVariables.continuousDesignRVs.begin(); it != theRandomVariables.continuousDesignRVs.end(); it++) - dakotaFile << it->upperBound << " "; - dakotaFile << "\n descriptors = "; - for (auto it = theRandomVariables.continuousDesignRVs.begin(); it != theRandomVariables.continuousDesignRVs.end(); it++) { - dakotaFile << "\'" << it->name << "\' "; - rvList.push_back(it->name); - } - dakotaFile << "\n\n"; + if (numContinuousDesign != 0) { + + if (!idVariables.empty()) { + dakotaFile << "id_variables = '" << idVariables << "'\n"; + } + + if (numContinuousDesign > 0) { + dakotaFile << " continuous_design = " << numContinuousDesign << "\n initial_point = "; + // std::list::iterator it; + for (auto it = theRandomVariables.continuousDesignRVs.begin(); it != theRandomVariables.continuousDesignRVs.end(); it++) + dakotaFile << it->initialPoint << " "; + dakotaFile << "\n lower_bounds = "; + for (auto it = theRandomVariables.continuousDesignRVs.begin(); it != theRandomVariables.continuousDesignRVs.end(); it++) + dakotaFile << it->lowerBound << " "; + dakotaFile << "\n upper_bounds = "; + for (auto it = theRandomVariables.continuousDesignRVs.begin(); it != theRandomVariables.continuousDesignRVs.end(); it++) + dakotaFile << it->upperBound << " "; + dakotaFile << "\n descriptors = "; + for (auto it = theRandomVariables.continuousDesignRVs.begin(); it != theRandomVariables.continuousDesignRVs.end(); it++) { + dakotaFile << "\'" << it->name << "\' "; + rvList.push_back(it->name); } + dakotaFile << "\n\n"; + } + + // sy - Constant in For optimization cases int numConstant = theRandomVariables.constantRVs.size(); if (numConstant > 0) { @@ -60,336 +65,357 @@ writeRV(std::ostream &dakotaFile, struct randomVariables &theRandomVariables, st dakotaFile << "\n\n"; } - int numRealDiscrete = theRandomVariables.discreteDesignSetRVs.size(); - if (numRealDiscrete > 0) { - dakotaFile << " discrete_design_set \n real = " << numRealDiscrete; - dakotaFile << "\n elements_per_variable = "; - for (auto it = theRandomVariables.discreteDesignSetRVs.begin(); it != theRandomVariables.discreteDesignSetRVs.end(); it++) - dakotaFile << it->elements.size() << " "; //std::list::iterator it; - dakotaFile << "\n elements = "; - for (auto it = theRandomVariables.discreteDesignSetRVs.begin(); it != theRandomVariables.discreteDesignSetRVs.end(); it++) { - it->elements.sort(); - for (auto element = it->elements.begin(); element != it->elements.end(); element++) - dakotaFile << " \'" << *element << "\'"; - } - dakotaFile << "\n descriptors = "; - for (auto it = theRandomVariables.discreteDesignSetRVs.begin(); it != theRandomVariables.discreteDesignSetRVs.end(); it++) { - dakotaFile << "\'" << it->name << "\' "; - rvList.push_back(it->name); - } - dakotaFile << "\n\n"; - } - - return 0; + return 0; + } + + + // sy - Constant in random analysis + + int numConstant = theRandomVariables.constantRVs.size(); + if (numConstant > 0) { + dakotaFile << " discrete_state_set \n real = " << numConstant; + dakotaFile << "\n elements_per_variable = "; + for (auto it = theRandomVariables.constantRVs.begin(); it != theRandomVariables.constantRVs.end(); it++) + dakotaFile << "1 "; //std::list::iterator it; + dakotaFile << "\n elements = "; + for (auto it = theRandomVariables.constantRVs.begin(); it != theRandomVariables.constantRVs.end(); it++) + dakotaFile << it->value << " "; + dakotaFile << "\n descriptors = "; + for (auto it = theRandomVariables.constantRVs.begin(); it != theRandomVariables.constantRVs.end(); it++) { + dakotaFile << "\'" << it->name << "\' "; + rvList.push_back(it->name); } + dakotaFile << "\n\n"; + } - if (includeActiveText == true) { - if (idVariables.empty()) - dakotaFile << "variables \n active uncertain \n"; - else - dakotaFile << "variables \n id_variables = '" << idVariables << "'\n active uncertain \n"; - } else { - dakotaFile << "variables \n"; + int numRealDiscrete = theRandomVariables.discreteDesignSetRVs.size(); + if (numRealDiscrete > 0) { + dakotaFile << " discrete_design_set \n real = " << numRealDiscrete; + dakotaFile << "\n elements_per_variable = "; + for (auto it = theRandomVariables.discreteDesignSetRVs.begin(); it != theRandomVariables.discreteDesignSetRVs.end(); it++) + dakotaFile << it->elements.size() << " "; //std::list::iterator it; + dakotaFile << "\n elements = "; + for (auto it = theRandomVariables.discreteDesignSetRVs.begin(); it != theRandomVariables.discreteDesignSetRVs.end(); it++) { + it->elements.sort(); + for (auto element = it->elements.begin(); element != it->elements.end(); element++) + dakotaFile << " \'" << *element << "\'"; + } + dakotaFile << "\n descriptors = "; + for (auto it = theRandomVariables.discreteDesignSetRVs.begin(); it != theRandomVariables.discreteDesignSetRVs.end(); it++) { + dakotaFile << "\'" << it->name << "\' "; + rvList.push_back(it->name); } + dakotaFile << "\n\n"; + } - // int numNormalUncertain = theRandomVariables.normalRVs.size(); - - int numNormal = theRandomVariables.normalRVs.size(); - if (theRandomVariables.normalRVs.size() > 0) { - dakotaFile << " normal_uncertain = " << numNormal << "\n means = "; - // std::list::iterator it; - for (auto it = theRandomVariables.normalRVs.begin(); it != theRandomVariables.normalRVs.end(); it++) - dakotaFile << it->mean << " "; - dakotaFile << "\n std_deviations = "; - for (auto it = theRandomVariables.normalRVs.begin(); it != theRandomVariables.normalRVs.end(); it++) - dakotaFile << it->stdDev << " "; - dakotaFile << "\n descriptors = "; - for (auto it = theRandomVariables.normalRVs.begin(); it != theRandomVariables.normalRVs.end(); it++) { - dakotaFile << "\'" << it->name << "\' "; - rvList.push_back(it->name); - } - dakotaFile << "\n\n"; + + + + if (includeActiveText == true) { + if (idVariables.empty()) + dakotaFile << "active uncertain \n"; + else + dakotaFile << "id_variables = '" << idVariables << "'\n active uncertain \n"; + } + // int numNormalUncertain = theRandomVariables.normalRVs.size(); + + int numNormal = theRandomVariables.normalRVs.size(); + if (theRandomVariables.normalRVs.size() > 0) { + dakotaFile << " normal_uncertain = " << numNormal << "\n means = "; + // std::list::iterator it; + for (auto it = theRandomVariables.normalRVs.begin(); it != theRandomVariables.normalRVs.end(); it++) + dakotaFile << it->mean << " "; + dakotaFile << "\n std_deviations = "; + for (auto it = theRandomVariables.normalRVs.begin(); it != theRandomVariables.normalRVs.end(); it++) + dakotaFile << it->stdDev << " "; + dakotaFile << "\n descriptors = "; + for (auto it = theRandomVariables.normalRVs.begin(); it != theRandomVariables.normalRVs.end(); it++) { + dakotaFile << "\'" << it->name << "\' "; + rvList.push_back(it->name); } - int numLognormal = theRandomVariables.lognormalRVs.size(); - if (numLognormal > 0) { - dakotaFile << " lognormal_uncertain = " << numLognormal << "\n means = "; - // std::list::iterator it; - for (auto it = theRandomVariables.lognormalRVs.begin(); it != theRandomVariables.lognormalRVs.end(); it++) - dakotaFile << it->mean << " "; - dakotaFile << "\n std_deviations = "; - for (auto it = theRandomVariables.lognormalRVs.begin(); it != theRandomVariables.lognormalRVs.end(); it++) - dakotaFile << it->stdDev << " "; - dakotaFile << "\n descriptors = "; - for (auto it = theRandomVariables.lognormalRVs.begin(); it != theRandomVariables.lognormalRVs.end(); it++) { - dakotaFile << "\'" << it->name << "\' "; - rvList.push_back(it->name); - } - dakotaFile << "\n\n"; + dakotaFile << "\n\n"; + } + + int numLognormal = theRandomVariables.lognormalRVs.size(); + if (numLognormal > 0) { + dakotaFile << " lognormal_uncertain = " << numLognormal << "\n means = "; + // std::list::iterator it; + for (auto it = theRandomVariables.lognormalRVs.begin(); it != theRandomVariables.lognormalRVs.end(); it++) + dakotaFile << it->mean << " "; + dakotaFile << "\n std_deviations = "; + for (auto it = theRandomVariables.lognormalRVs.begin(); it != theRandomVariables.lognormalRVs.end(); it++) + dakotaFile << it->stdDev << " "; + dakotaFile << "\n descriptors = "; + for (auto it = theRandomVariables.lognormalRVs.begin(); it != theRandomVariables.lognormalRVs.end(); it++) { + dakotaFile << "\'" << it->name << "\' "; + rvList.push_back(it->name); } + dakotaFile << "\n\n"; + } - int numUniform = theRandomVariables.uniformRVs.size(); - if (numUniform > 0) { - dakotaFile << " uniform_uncertain = " << numUniform << "\n lower_bounds = "; - // std::list::iterator it; - for (auto it = theRandomVariables.uniformRVs.begin(); it != theRandomVariables.uniformRVs.end(); it++) - dakotaFile << it->lowerBound << " "; - dakotaFile << "\n upper_bound = "; - for (auto it = theRandomVariables.uniformRVs.begin(); it != theRandomVariables.uniformRVs.end(); it++) - dakotaFile << it->upperBound << " "; - dakotaFile << "\n descriptors = "; - for (auto it = theRandomVariables.uniformRVs.begin(); it != theRandomVariables.uniformRVs.end(); it++) { - dakotaFile << "\'" << it->name << "\' "; - rvList.push_back(it->name); - } - dakotaFile << "\n\n"; + int numUniform = theRandomVariables.uniformRVs.size(); + if (numUniform > 0) { + dakotaFile << " uniform_uncertain = " << numUniform << "\n lower_bounds = "; + // std::list::iterator it; + for (auto it = theRandomVariables.uniformRVs.begin(); it != theRandomVariables.uniformRVs.end(); it++) + dakotaFile << it->lowerBound << " "; + dakotaFile << "\n upper_bound = "; + for (auto it = theRandomVariables.uniformRVs.begin(); it != theRandomVariables.uniformRVs.end(); it++) + dakotaFile << it->upperBound << " "; + dakotaFile << "\n descriptors = "; + for (auto it = theRandomVariables.uniformRVs.begin(); it != theRandomVariables.uniformRVs.end(); it++) { + dakotaFile << "\'" << it->name << "\' "; + rvList.push_back(it->name); } + dakotaFile << "\n\n"; + } - int numWeibull = theRandomVariables.weibullRVs.size(); - if (numWeibull > 0) { - dakotaFile << " weibull_uncertain = " << numWeibull << "\n alphas = "; - // std::list::iterator it; - for (auto it = theRandomVariables.weibullRVs.begin(); it != theRandomVariables.weibullRVs.end(); it++) - dakotaFile << it->shapeParam << " "; - dakotaFile << "\n betas = "; - for (auto it = theRandomVariables.weibullRVs.begin(); it != theRandomVariables.weibullRVs.end(); it++) - dakotaFile << it->scaleParam << " "; - dakotaFile << "\n descriptors = "; - for (auto it = theRandomVariables.weibullRVs.begin(); it != theRandomVariables.weibullRVs.end(); it++) { - dakotaFile << "\'" << it->name << "\' "; - rvList.push_back(it->name); - } - dakotaFile << "\n\n"; + int numWeibull = theRandomVariables.weibullRVs.size(); + if (numWeibull > 0) { + dakotaFile << " weibull_uncertain = " << numWeibull << "\n alphas = "; + // std::list::iterator it; + for (auto it = theRandomVariables.weibullRVs.begin(); it != theRandomVariables.weibullRVs.end(); it++) + dakotaFile << it->shapeParam << " "; + dakotaFile << "\n betas = "; + for (auto it = theRandomVariables.weibullRVs.begin(); it != theRandomVariables.weibullRVs.end(); it++) + dakotaFile << it->scaleParam << " "; + dakotaFile << "\n descriptors = "; + for (auto it = theRandomVariables.weibullRVs.begin(); it != theRandomVariables.weibullRVs.end(); it++) { + dakotaFile << "\'" << it->name << "\' "; + rvList.push_back(it->name); } + dakotaFile << "\n\n"; + } - int numGumbell = theRandomVariables.gumbellRVs.size(); - if (numGumbell > 0) { - dakotaFile << " gumbel_uncertain = " << numGumbell << "\n alphas = "; - // std::list::iterator it; - for (auto it = theRandomVariables.gumbellRVs.begin(); it != theRandomVariables.gumbellRVs.end(); it++) - dakotaFile << it->alphas << " "; - dakotaFile << "\n betas = "; - for (auto it = theRandomVariables.gumbellRVs.begin(); it != theRandomVariables.gumbellRVs.end(); it++) - dakotaFile << it->betas << " "; - dakotaFile << "\n descriptors = "; - for (auto it = theRandomVariables.gumbellRVs.begin(); it != theRandomVariables.gumbellRVs.end(); it++) { - dakotaFile << "\'" << it->name << "\' "; - rvList.push_back(it->name); - } - dakotaFile << "\n\n"; + int numGumbell = theRandomVariables.gumbellRVs.size(); + if (numGumbell > 0) { + dakotaFile << " gumbel_uncertain = " << numGumbell << "\n alphas = "; + // std::list::iterator it; + for (auto it = theRandomVariables.gumbellRVs.begin(); it != theRandomVariables.gumbellRVs.end(); it++) + dakotaFile << it->alphas << " "; + dakotaFile << "\n betas = "; + for (auto it = theRandomVariables.gumbellRVs.begin(); it != theRandomVariables.gumbellRVs.end(); it++) + dakotaFile << it->betas << " "; + dakotaFile << "\n descriptors = "; + for (auto it = theRandomVariables.gumbellRVs.begin(); it != theRandomVariables.gumbellRVs.end(); it++) { + dakotaFile << "\'" << it->name << "\' "; + rvList.push_back(it->name); } + dakotaFile << "\n\n"; + } - int numGamma = theRandomVariables.gammaRVs.size(); - if (numGamma > 0) { - dakotaFile << " gamma_uncertain = " << numGamma << "\n alphas = "; - std::list::iterator it; - for (auto it = theRandomVariables.gammaRVs.begin(); it != theRandomVariables.gammaRVs.end(); it++) - dakotaFile << it->alphas << " "; - dakotaFile << "\n betas = "; - for (auto it = theRandomVariables.gammaRVs.begin(); it != theRandomVariables.gammaRVs.end(); it++) - dakotaFile << it->betas << " "; - dakotaFile << "\n descriptors = "; - for (auto it = theRandomVariables.gammaRVs.begin(); it != theRandomVariables.gammaRVs.end(); it++) { - dakotaFile << "\'" << it->name << "\' "; - rvList.push_back(it->name); - } - dakotaFile << "\n\n"; + int numGamma = theRandomVariables.gammaRVs.size(); + if (numGamma > 0) { + dakotaFile << " gamma_uncertain = " << numGamma << "\n alphas = "; + std::list::iterator it; + for (auto it = theRandomVariables.gammaRVs.begin(); it != theRandomVariables.gammaRVs.end(); it++) + dakotaFile << it->alphas << " "; + dakotaFile << "\n betas = "; + for (auto it = theRandomVariables.gammaRVs.begin(); it != theRandomVariables.gammaRVs.end(); it++) + dakotaFile << it->betas << " "; + dakotaFile << "\n descriptors = "; + for (auto it = theRandomVariables.gammaRVs.begin(); it != theRandomVariables.gammaRVs.end(); it++) { + dakotaFile << "\'" << it->name << "\' "; + rvList.push_back(it->name); } + dakotaFile << "\n\n"; + } - int numBeta = theRandomVariables.betaRVs.size(); - if (numBeta > 0) { - dakotaFile << " beta_uncertain = " << numBeta << "\n alphas = "; - //std::list::iterator it; - for (auto it = theRandomVariables.betaRVs.begin(); it != theRandomVariables.betaRVs.end(); it++) - dakotaFile << it->alphas << " "; - dakotaFile << "\n betas = "; - for (auto it = theRandomVariables.betaRVs.begin(); it != theRandomVariables.betaRVs.end(); it++) - dakotaFile << it->betas << " "; - dakotaFile << "\n lower_bounds = "; - for (auto it = theRandomVariables.betaRVs.begin(); it != theRandomVariables.betaRVs.end(); it++) - dakotaFile << it->lowerBound << " "; - dakotaFile << "\n upper_bounds = "; - for (auto it = theRandomVariables.betaRVs.begin(); it != theRandomVariables.betaRVs.end(); it++) - dakotaFile << it->upperBound << " "; - dakotaFile << "\n descriptors = "; - for (auto it = theRandomVariables.betaRVs.begin(); it != theRandomVariables.betaRVs.end(); it++) { - dakotaFile << "\'" << it->name << "\' "; - rvList.push_back(it->name); - } - dakotaFile << "\n\n"; + int numBeta = theRandomVariables.betaRVs.size(); + if (numBeta > 0) { + dakotaFile << " beta_uncertain = " << numBeta << "\n alphas = "; + //std::list::iterator it; + for (auto it = theRandomVariables.betaRVs.begin(); it != theRandomVariables.betaRVs.end(); it++) + dakotaFile << it->alphas << " "; + dakotaFile << "\n betas = "; + for (auto it = theRandomVariables.betaRVs.begin(); it != theRandomVariables.betaRVs.end(); it++) + dakotaFile << it->betas << " "; + dakotaFile << "\n lower_bounds = "; + for (auto it = theRandomVariables.betaRVs.begin(); it != theRandomVariables.betaRVs.end(); it++) + dakotaFile << it->lowerBound << " "; + dakotaFile << "\n upper_bounds = "; + for (auto it = theRandomVariables.betaRVs.begin(); it != theRandomVariables.betaRVs.end(); it++) + dakotaFile << it->upperBound << " "; + dakotaFile << "\n descriptors = "; + for (auto it = theRandomVariables.betaRVs.begin(); it != theRandomVariables.betaRVs.end(); it++) { + dakotaFile << "\'" << it->name << "\' "; + rvList.push_back(it->name); } + dakotaFile << "\n\n"; + } - int numExponential = theRandomVariables.exponentialRVs.size(); - if (numExponential > 0) { - dakotaFile << " exponential_uncertain = " << numExponential << "\n betas = "; - for (auto it = theRandomVariables.betaRVs.begin(); it != theRandomVariables.betaRVs.end(); it++) - dakotaFile << it->alphas << " "; - dakotaFile << "\n descriptors = "; - for (auto it = theRandomVariables.exponentialRVs.begin(); it != theRandomVariables.exponentialRVs.end(); it++) { - dakotaFile << "\'" << it->name << "\' "; - rvList.push_back(it->name); + int numExponential = theRandomVariables.exponentialRVs.size(); + if (numExponential > 0) { + dakotaFile << " exponential_uncertain = " << numExponential << "\n betas = "; + for (auto it = theRandomVariables.betaRVs.begin(); it != theRandomVariables.betaRVs.end(); it++) + dakotaFile << it->alphas << " "; + dakotaFile << "\n descriptors = "; + for (auto it = theRandomVariables.exponentialRVs.begin(); it != theRandomVariables.exponentialRVs.end(); it++) { + dakotaFile << "\'" << it->name << "\' "; + rvList.push_back(it->name); + } + dakotaFile << "\n\n"; + } + + // int numConstant = theRandomVariables.constantRVs.size(); + // if (numConstant > 0) { + // dakotaFile << " discrete_state_set \n real = " << numConstant; + // dakotaFile << "\n elements_per_variable = "; + // for (auto it = theRandomVariables.constantRVs.begin(); it != theRandomVariables.constantRVs.end(); it++) + // dakotaFile << "1 "; //std::list::iterator it; + // dakotaFile << "\n elements = "; + // for (auto it = theRandomVariables.constantRVs.begin(); it != theRandomVariables.constantRVs.end(); it++) + // dakotaFile << it->value << " "; + // dakotaFile << "\n descriptors = "; + // for (auto it = theRandomVariables.constantRVs.begin(); it != theRandomVariables.constantRVs.end(); it++) { + // dakotaFile << "\'" << it->name << "\' "; + // rvList.push_back(it->name); + // } + // dakotaFile << "\n\n"; + // } + + // discreteUncertainSetRVs - int, string, real + std::list theDiscreteIntList; + std::list theDiscreteRealList; + std::list theDiscreteStringList; + + int numDiscreteInt = theRandomVariables.discreteUncertainIntegerSetRVs.size(); + int numDiscreteString = theRandomVariables.discreteDesignSetRVs.size(); + int numDiscreteReal = theRandomVariables.discreteUncertainRealSetRVs.size(); + + // std::cerr << "DISCRETE: numInt: " << numDiscreteInt << " numReal: " << numDiscreteReal << "\n"; + + if (numDiscreteInt != 0 || numDiscreteReal != 0 || numDiscreteString != 0) { + + dakotaFile << " discrete_uncertain_set"; + + if (numDiscreteInt != 0) { + + theDiscreteIntList = theRandomVariables.discreteUncertainIntegerSetRVs; + + dakotaFile << "\n integer = " << theDiscreteIntList.size(); + dakotaFile << "\n num_set_values = "; + for (auto it = theDiscreteIntList.begin(); it != theDiscreteIntList.end(); it++) + dakotaFile << it->elements.size() << " "; + dakotaFile << "\n set_values = "; + for (auto it = theDiscreteIntList.begin(); it != theDiscreteIntList.end(); it++) { + auto elementsList = it->elements; + for (auto eit = elementsList.begin(); eit != elementsList.end(); eit++) + dakotaFile << *eit << " "; + dakotaFile << " "; } - dakotaFile << "\n\n"; - } - - // int numConstant = theRandomVariables.constantRVs.size(); - // if (numConstant > 0) { - // dakotaFile << " discrete_state_set \n real = " << numConstant; - // dakotaFile << "\n elements_per_variable = "; - // for (auto it = theRandomVariables.constantRVs.begin(); it != theRandomVariables.constantRVs.end(); it++) - // dakotaFile << "1 "; //std::list::iterator it; - // dakotaFile << "\n elements = "; - // for (auto it = theRandomVariables.constantRVs.begin(); it != theRandomVariables.constantRVs.end(); it++) - // dakotaFile << it->value << " "; - // dakotaFile << "\n descriptors = "; - // for (auto it = theRandomVariables.constantRVs.begin(); it != theRandomVariables.constantRVs.end(); it++) { - // dakotaFile << "\'" << it->name << "\' "; - // rvList.push_back(it->name); - // } - // dakotaFile << "\n\n"; - // } - - // discreteUncertainSetRVs - int, string, real - std::list theDiscreteIntList; - std::list theDiscreteRealList; - std::list theDiscreteStringList; - - int numDiscreteInt = theRandomVariables.discreteUncertainIntegerSetRVs.size(); - int numDiscreteString = theRandomVariables.discreteDesignSetRVs.size(); - int numDiscreteReal = theRandomVariables.discreteUncertainRealSetRVs.size(); - - // std::cerr << "DISCRETE: numInt: " << numDiscreteInt << " numReal: " << numDiscreteReal << "\n"; - - if (numDiscreteInt != 0 || numDiscreteReal != 0 || numDiscreteString != 0) { - - dakotaFile << " discrete_uncertain_set"; - - if (numDiscreteInt != 0) { - - theDiscreteIntList = theRandomVariables.discreteUncertainIntegerSetRVs; - - dakotaFile << "\n integer = " << theDiscreteIntList.size(); - dakotaFile << "\n num_set_values = "; - for (auto it = theDiscreteIntList.begin(); it != theDiscreteIntList.end(); it++) - dakotaFile << it->elements.size() << " "; - dakotaFile << "\n set_values = "; - for (auto it = theDiscreteIntList.begin(); it != theDiscreteIntList.end(); it++) { - auto elementsList = it->elements; - for (auto eit = elementsList.begin(); eit != elementsList.end(); eit++) - dakotaFile << *eit << " "; - dakotaFile << " "; - } - dakotaFile << "\n set_probabilities = "; - for (auto it = theDiscreteIntList.begin(); it != theDiscreteIntList.end(); it++) { - auto probsList = it->weights; - for (auto pit = probsList.begin(); pit != probsList.end(); pit++) - dakotaFile << *pit << " "; - dakotaFile << " "; - } - dakotaFile << "\n descriptors = "; - for (auto it = theDiscreteIntList.begin(); it != theDiscreteIntList.end(); it++) - dakotaFile << "\'" << it->name << "\' "; + dakotaFile << "\n set_probabilities = "; + for (auto it = theDiscreteIntList.begin(); it != theDiscreteIntList.end(); it++) { + auto probsList = it->weights; + for (auto pit = probsList.begin(); pit != probsList.end(); pit++) + dakotaFile << *pit << " "; + dakotaFile << " "; } + dakotaFile << "\n descriptors = "; + for (auto it = theDiscreteIntList.begin(); it != theDiscreteIntList.end(); it++) + dakotaFile << "\'" << it->name << "\' "; + } - if (numDiscreteReal != 0) { - - theDiscreteRealList = theRandomVariables.discreteUncertainRealSetRVs; - - dakotaFile << "\n real = " << theDiscreteRealList.size(); - dakotaFile << "\n num_set_values = "; - for (auto it = theDiscreteRealList.begin(); it != theDiscreteRealList.end(); it++) - dakotaFile << it->elements.size() << " "; - dakotaFile << "\n set_values = "; - for (auto it = theDiscreteRealList.begin(); it != theDiscreteRealList.end(); it++) { - auto elementsList = it->elements; - for (auto eit = elementsList.begin(); eit != elementsList.end(); eit++) - dakotaFile << *eit << " "; - dakotaFile << " "; - } - dakotaFile << "\n set_probabilities = "; - for (auto it = theDiscreteRealList.begin(); it != theDiscreteRealList.end(); it++) { - auto probsList = it->weights; - for (auto pit = probsList.begin(); pit != probsList.end(); pit++) - dakotaFile << *pit << " "; - dakotaFile << " "; - } - dakotaFile << "\n descriptors = "; - for (auto it = theDiscreteRealList.begin(); it != theDiscreteRealList.end(); it++) - dakotaFile << "\'" << it->name << "\' "; + if (numDiscreteReal != 0) { + + theDiscreteRealList = theRandomVariables.discreteUncertainRealSetRVs; + + dakotaFile << "\n real = " << theDiscreteRealList.size(); + dakotaFile << "\n num_set_values = "; + for (auto it = theDiscreteRealList.begin(); it != theDiscreteRealList.end(); it++) + dakotaFile << it->elements.size() << " "; + dakotaFile << "\n set_values = "; + for (auto it = theDiscreteRealList.begin(); it != theDiscreteRealList.end(); it++) { + auto elementsList = it->elements; + for (auto eit = elementsList.begin(); eit != elementsList.end(); eit++) + dakotaFile << *eit << " "; + dakotaFile << " "; } - - - if (numDiscreteString != 0) { - - theDiscreteStringList = theRandomVariables.discreteDesignSetRVs; - - dakotaFile << "\n string = " << theDiscreteStringList.size(); - dakotaFile << "\n num_set_values = "; - for (auto it = theDiscreteStringList.begin(); it != theDiscreteStringList.end(); it++) - dakotaFile << it->elements.size() << " "; - dakotaFile << "\n set_values = "; - for (auto it = theDiscreteStringList.begin(); it != theDiscreteStringList.end(); it++) { - it->elements.sort(); // sort the elements NEEDED THOUGH NOT IN DAKOTA DOC! - for (auto element = it->elements.begin(); element != it->elements.end(); element++) - dakotaFile << " \'" << *element << "\'"; - } - dakotaFile << "\n descriptors = "; - for (auto it = theDiscreteStringList.begin(); it != theDiscreteStringList.end(); it++) { - dakotaFile << "\'" << it->name << "\' "; - } + dakotaFile << "\n set_probabilities = "; + for (auto it = theDiscreteRealList.begin(); it != theDiscreteRealList.end(); it++) { + auto probsList = it->weights; + for (auto pit = probsList.begin(); pit != probsList.end(); pit++) + dakotaFile << *pit << " "; + dakotaFile << " "; } - dakotaFile << "\n\n"; + dakotaFile << "\n descriptors = "; + for (auto it = theDiscreteRealList.begin(); it != theDiscreteRealList.end(); it++) + dakotaFile << "\'" << it->name << "\' "; } - // if no random variables .. create 1 call & call it dummy! - int numRV = theRandomVariables.numRandomVariables; - if (numRV == 0) { - dakotaFile << " discrete_uncertain_set\n string 1 \n num_set_values = 2"; - dakotaFile << "\n set_values '1' '2'"; - dakotaFile << "\n descriptors = dummy\n"; - rvList.push_back(std::string("dummy")); + if (numDiscreteString != 0) { + + theDiscreteStringList = theRandomVariables.discreteDesignSetRVs; + + dakotaFile << "\n string = " << theDiscreteStringList.size(); + dakotaFile << "\n num_set_values = "; + for (auto it = theDiscreteStringList.begin(); it != theDiscreteStringList.end(); it++) + dakotaFile << it->elements.size() << " "; + dakotaFile << "\n set_values = "; + for (auto it = theDiscreteStringList.begin(); it != theDiscreteStringList.end(); it++) { + it->elements.sort(); // sort the elements NEEDED THOUGH NOT IN DAKOTA DOC! + for (auto element = it->elements.begin(); element != it->elements.end(); element++) + dakotaFile << " \'" << *element << "\'"; + } + dakotaFile << "\n descriptors = "; + for (auto it = theDiscreteStringList.begin(); it != theDiscreteStringList.end(); it++) { + dakotaFile << "\'" << it->name << "\' "; + } } dakotaFile << "\n\n"; + } + + + // if no random variables .. create 1 call & call it dummy! + int numRV = theRandomVariables.numRandomVariables; + if (numRV == 0) { + dakotaFile << " discrete_uncertain_set\n string 1 \n num_set_values = 2"; + dakotaFile << "\n set_values '1' '2'"; + dakotaFile << "\n descriptors = dummy\n"; + rvList.push_back(std::string("dummy")); + } + dakotaFile << "\n\n"; + + int corrSize = theRandomVariables.ordering.size(); - int corrSize = theRandomVariables.ordering.size(); - - /* ***************************************************** - if (!theRandomVariables.corrMat.empty()) { - - if (theRandomVariables.corrMat[0] !=0 ) { - - std::cerr << "NEW ORDER: \n" << " size: " << corrSize << "\n"; - std::vector newOrder; - - for (int i=0; i<18; i++) { - for (int j=0; j newOrder; + + for (int i=0; i<18; i++) { + for (int j=0; j &edpList, - const char *calFileName, - std::vector &scaleFactors) { - + const char *calFileName, + std::vector &scaleFactors) { + int numResponses = 0; dakotaFile << "responses\n"; @@ -459,35 +485,35 @@ writeResponse(std::ostream &dakotaFile, // // quoFEM .. just a list of straight EDP // - + numResponses = json_array_size(rootEDP); - + std::vector lenList(numResponses, 1); - + int numFieldResponses = 0; int numScalarResponses = 0; - - if (!(idResponse.compare("calibration") == 0 || idResponse.compare("BayesCalibration") == 0 || idResponse.compare("optimization") == 0)){ + + if (!(idResponse.compare("calibration") == 0 || idResponse.compare("BayesCalibration") == 0 || idResponse.compare("optimization") == 0)) { dakotaFile << " response_functions = " << numResponses << "\n response_descriptors = "; } else if (idResponse.compare("optimization") == 0) { dakotaFile << " objective_functions = " << numResponses << "\n descriptors = "; } else dakotaFile << " calibration_terms = " << numResponses << "\n response_descriptors = "; - - for (int j=0; j 0) { if (!(idResponse.compare("calibration") == 0 || idResponse.compare("BayesCalibration") == 0)) { if (numScalarResponses > 0) { - dakotaFile << "\n scalar_responses = " << numScalarResponses; + dakotaFile << "\n scalar_responses = " << numScalarResponses; } dakotaFile << "\n field_responses = " << numFieldResponses << "\n lengths = "; } else { if (numScalarResponses > 0) { - dakotaFile << "\n scalar_calibration_terms = " << numScalarResponses; + dakotaFile << "\n scalar_calibration_terms = " << numScalarResponses; } dakotaFile << "\n field_calibration_terms = " << numFieldResponses << "\n lengths = "; } @@ -509,12 +535,12 @@ writeResponse(std::ostream &dakotaFile, json_t *theEDP_Item = json_array_get(rootEDP, j); std::string varType = json_string_value(json_object_get(theEDP_Item, "type")); if (varType.compare("field") == 0) { - int len = json_integer_value(json_object_get(theEDP_Item, "length")); - dakotaFile << len << " "; - lenList[j] = len; + int len = json_integer_value(json_object_get(theEDP_Item, "length")); + dakotaFile << len << " "; + lenList[j] = len; } } - + // bool readFieldCoords = true; // if (readFieldCoords) { // dakotaFile << "\n read_field_coordinates" << "\n num_coordinates_per_field = "; @@ -527,40 +553,40 @@ writeResponse(std::ostream &dakotaFile, // // } } - + if ((idResponse.compare("calibration") == 0) || (idResponse.compare("BayesCalibration") == 0)) { std::vector errFilenameList = {}; std::stringstream errTypeStringStream; - + int numExp = processDataFiles(calFileName, edpList, lenList, numResponses, numFieldResponses, errFilenameList, - errTypeStringStream, idResponse, scaleFactors); - + errTypeStringStream, idResponse, scaleFactors); + bool readCalibrationData = true; if (readCalibrationData) { if (numFieldResponses > 0) { - int nExp = numExp; - if (nExp < 1) { - nExp = 1; - } - dakotaFile << "\n calibration_data"; - dakotaFile << "\n num_experiments = " << nExp; - if (idResponse.compare("BayesCalibration") == 0) { - dakotaFile << "\n experiment_variance_type = "; - dakotaFile << errTypeStringStream.str(); - } + int nExp = numExp; + if (nExp < 1) { + nExp = 1; + } + dakotaFile << "\n calibration_data"; + dakotaFile << "\n num_experiments = " << nExp; + if (idResponse.compare("BayesCalibration") == 0) { + dakotaFile << "\n experiment_variance_type = "; + dakotaFile << errTypeStringStream.str(); + } } else { - int nExp = numExp; - if (nExp < 1) { - nExp = 1; - } - dakotaFile << "\n calibration_data_file = 'quoFEMScalarCalibrationData.cal'"; - dakotaFile << "\n freeform"; - dakotaFile << "\n num_experiments = " << nExp; - if (idResponse.compare("BayesCalibration") == 0) { - dakotaFile << "\n experiment_variance_type = "; - dakotaFile << errTypeStringStream.str(); - } + int nExp = numExp; + if (nExp < 1) { + nExp = 1; + } + dakotaFile << "\n calibration_data_file = 'quoFEMScalarCalibrationData.cal'"; + dakotaFile << "\n freeform"; + dakotaFile << "\n num_experiments = " << nExp; + if (idResponse.compare("BayesCalibration") == 0) { + dakotaFile << "\n experiment_variance_type = "; + dakotaFile << errTypeStringStream.str(); + } } } } @@ -582,13 +608,13 @@ writeResponse(std::ostream &dakotaFile, int writeDakotaInputFile(std::ostream &dakotaFile, - json_t *uqData, - json_t *rootEDP, - struct randomVariables &theRandomVariables, - std::string &workflowDriver, - std::vector &rvList, - std::vector &edpList, - int evalConcurrency) { + json_t *uqData, + json_t *rootEDP, + struct randomVariables &theRandomVariables, + std::string &workflowDriver, + std::vector &rvList, + std::vector &edpList, + int evalConcurrency) { int evaluationConcurrency = evalConcurrency; @@ -601,7 +627,7 @@ writeDakotaInputFile(std::ostream &dakotaFile, } // Save all the working dirs? bool saveWorkDirs = true; - json_t *saveDirs = json_object_get(uqData,"saveWorkDir"); + json_t *saveDirs = json_object_get(uqData, "saveWorkDir"); if (saveDirs != NULL) { if (json_is_false(saveDirs)) saveWorkDirs = false; @@ -612,10 +638,10 @@ writeDakotaInputFile(std::ostream &dakotaFile, if (strcmp(type, "Sensitivity Analysis") == 0) sensitivityAnalysis = true; - json_t *EDPs = json_object_get(rootEDP,"EngineeringDemandParameters"); + json_t *EDPs = json_object_get(rootEDP, "EngineeringDemandParameters"); int numResponses = 0; if (EDPs != NULL) { - numResponses = json_integer_value(json_object_get(rootEDP,"total_number_edp")); + numResponses = json_integer_value(json_object_get(rootEDP, "total_number_edp")); } else { numResponses = json_array_size(rootEDP); } @@ -626,19 +652,19 @@ writeDakotaInputFile(std::ostream &dakotaFile, if ((strcmp(type, "Forward Propagation") == 0) || sensitivityAnalysis == true) { - json_t *samplingMethodData = json_object_get(uqData,"samplingMethodData"); + json_t *samplingMethodData = json_object_get(uqData, "samplingMethodData"); - const char *method = json_string_value(json_object_get(samplingMethodData,"method")); + const char *method = json_string_value(json_object_get(samplingMethodData, "method")); - if (strcmp(method,"Monte Carlo")==0) { - int numSamples = json_integer_value(json_object_get(samplingMethodData,"samples")); - int seed = json_integer_value(json_object_get(samplingMethodData,"seed")); + if (strcmp(method, "Monte Carlo") == 0) { + int numSamples = json_integer_value(json_object_get(samplingMethodData, "samples")); + int seed = json_integer_value(json_object_get(samplingMethodData, "seed")); dakotaFile << "environment \n tabular_data \n tabular_data_file = 'dakotaTab.out' \n\n"; dakotaFile << "method, \n sampling \n sample_type = random \n samples = " << numSamples << " \n seed = " << seed << "\n\n"; if (sensitivityAnalysis == true) - dakotaFile << "variance_based_decomp \n\n"; + dakotaFile << "variance_based_decomp \n\n"; const char * calFileName = new char[1]; std::string emptyString; @@ -648,10 +674,10 @@ writeDakotaInputFile(std::ostream &dakotaFile, writeResponse(dakotaFile, rootEDP, emptyString, false, false, edpList, calFileName, scaleFactors); } - else if (strcmp(method,"LHS")==0) { + else if (strcmp(method, "LHS") == 0) { - int numSamples = json_integer_value(json_object_get(samplingMethodData,"samples")); - int seed = json_integer_value(json_object_get(samplingMethodData,"seed")); + int numSamples = json_integer_value(json_object_get(samplingMethodData, "samples")); + int seed = json_integer_value(json_object_get(samplingMethodData, "seed")); //std::cerr << numSamples << " " << seed; @@ -659,7 +685,7 @@ writeDakotaInputFile(std::ostream &dakotaFile, dakotaFile << "method,\n sampling\n sample_type = lhs \n samples = " << numSamples << " \n seed = " << seed << "\n\n"; if (sensitivityAnalysis == true) - dakotaFile << "variance_based_decomp \n\n"; + dakotaFile << "variance_based_decomp \n\n"; const char * calFileName = new char[1]; @@ -688,23 +714,23 @@ writeDakotaInputFile(std::ostream &dakotaFile, } */ // } - else if (strcmp(method,"Gaussian Process Regression")==0) { + else if (strcmp(method, "Gaussian Process Regression") == 0) { - int trainingSamples = json_integer_value(json_object_get(samplingMethodData,"trainingSamples")); - int trainingSeed = json_integer_value(json_object_get(samplingMethodData,"trainingSeed")); - const char *trainMethod = json_string_value(json_object_get(samplingMethodData,"trainingMethod")); - int samplingSamples = json_integer_value(json_object_get(samplingMethodData,"samplingSamples")); - int samplingSeed = json_integer_value(json_object_get(samplingMethodData,"samplingSeed")); - const char *sampleMethod = json_string_value(json_object_get(samplingMethodData,"samplingMethod")); + int trainingSamples = json_integer_value(json_object_get(samplingMethodData, "trainingSamples")); + int trainingSeed = json_integer_value(json_object_get(samplingMethodData, "trainingSeed")); + const char *trainMethod = json_string_value(json_object_get(samplingMethodData, "trainingMethod")); + int samplingSamples = json_integer_value(json_object_get(samplingMethodData, "samplingSamples")); + int samplingSeed = json_integer_value(json_object_get(samplingMethodData, "samplingSeed")); + const char *sampleMethod = json_string_value(json_object_get(samplingMethodData, "samplingMethod")); - const char *surrogateMethod = json_string_value(json_object_get(samplingMethodData,"surrogateSurfaceMethod")); + const char *surrogateMethod = json_string_value(json_object_get(samplingMethodData, "surrogateSurfaceMethod")); std::string trainingMethod(trainMethod); std::string samplingMethod(sampleMethod); - if (strcmp(trainMethod,"Monte Carlo") == 0) - trainingMethod = "random"; - if (strcmp(sampleMethod,"Monte Carlo") == 0) - samplingMethod = "random"; + if (strcmp(trainMethod, "Monte Carlo") == 0) + trainingMethod = "random"; + if (strcmp(sampleMethod, "Monte Carlo") == 0) + samplingMethod = "random"; dakotaFile << "environment \n method_pointer = 'SurrogateMethod' \n tabular_data \n tabular_data_file = 'dakotaTab.out'\n"; @@ -712,14 +738,14 @@ writeDakotaInputFile(std::ostream &dakotaFile, dakotaFile << "method \n id_method = 'SurrogateMethod' \n model_pointer = 'SurrogateModel'\n"; dakotaFile << " sampling \n samples = " << samplingSamples << "\n seed = " << samplingSeed << "\n sample_type = " - << samplingMethod << "\n\n"; + << samplingMethod << "\n\n"; dakotaFile << "model \n id_model = 'SurrogateModel' \n surrogate global \n dace_method_pointer = 'TrainingMethod'\n " - << surrogateMethod << "\n\n"; + << surrogateMethod << "\n\n"; dakotaFile << "method \n id_method = 'TrainingMethod' \n model_pointer = 'TrainingModel'\n"; dakotaFile << " sampling \n samples = " << trainingSamples << "\n seed = " << trainingSeed << "\n sample_type = " - << trainingMethod << "\n\n"; + << trainingMethod << "\n\n"; dakotaFile << "model \n id_model = 'TrainingModel' \n single \n interface_pointer = 'SimulationInterface'"; const char * calFileName = new char[1]; @@ -732,29 +758,29 @@ writeDakotaInputFile(std::ostream &dakotaFile, } - else if (strcmp(method,"Polynomial Chaos Expansion")==0) { + else if (strcmp(method, "Polynomial Chaos Expansion") == 0) { - const char *dataMethod = json_string_value(json_object_get(samplingMethodData,"dataMethod")); - int intValue = json_integer_value(json_object_get(samplingMethodData,"level")); - int samplingSeed = json_integer_value(json_object_get(samplingMethodData,"samplingSeed")); - int samplingSamples = json_integer_value(json_object_get(samplingMethodData,"samplingSamples")); - const char *sampleMethod = json_string_value(json_object_get(samplingMethodData,"samplingMethod")); + const char *dataMethod = json_string_value(json_object_get(samplingMethodData, "dataMethod")); + int intValue = json_integer_value(json_object_get(samplingMethodData, "level")); + int samplingSeed = json_integer_value(json_object_get(samplingMethodData, "samplingSeed")); + int samplingSamples = json_integer_value(json_object_get(samplingMethodData, "samplingSamples")); + const char *sampleMethod = json_string_value(json_object_get(samplingMethodData, "samplingMethod")); std::string pceMethod; - if (strcmp(dataMethod,"Quadrature") == 0) - pceMethod = "quadrature_order = "; - else if (strcmp(dataMethod,"Smolyak Sparse_Grid") == 0) - pceMethod = "sparse_grid_level = "; - else if (strcmp(dataMethod,"Stroud Cubature") == 0) - pceMethod = "cubature_integrand = "; - else if (strcmp(dataMethod,"Orthogonal Least_Interpolation") == 0) - pceMethod = "orthogonal_least_squares collocation_points = "; + if (strcmp(dataMethod, "Quadrature") == 0) + pceMethod = "quadrature_order = "; + else if (strcmp(dataMethod, "Smolyak Sparse_Grid") == 0) + pceMethod = "sparse_grid_level = "; + else if (strcmp(dataMethod, "Stroud Cubature") == 0) + pceMethod = "cubature_integrand = "; + else if (strcmp(dataMethod, "Orthogonal Least_Interpolation") == 0) + pceMethod = "orthogonal_least_squares collocation_points = "; else - pceMethod = "quadrature_order = "; + pceMethod = "quadrature_order = "; std::string samplingMethod(sampleMethod); - if (strcmp(sampleMethod,"Monte Carlo") == 0) - samplingMethod = "random"; + if (strcmp(sampleMethod, "Monte Carlo") == 0) + samplingMethod = "random"; dakotaFile << "environment \n tabular_data \n tabular_data_file = 'a.out'\n\n"; // a.out for trial data const char * calFileName = new char[1]; @@ -767,10 +793,10 @@ writeDakotaInputFile(std::ostream &dakotaFile, dakotaFile << "method \n polynomial_chaos \n " << pceMethod << intValue; dakotaFile << "\n samples_on_emulator = " << samplingSamples << "\n seed = " << samplingSeed << "\n sample_type = " - << samplingMethod << "\n"; + << samplingMethod << "\n"; dakotaFile << " probability_levels = "; - for (int i=0; i> tmp) { -// // maybe some checks, i.e. , -// dakotaFile << tmp << " "; +// // maybe some checks, i.e. , +// dakotaFile << tmp << " "; // } // dakotaFile << "\n"; // } } else if ((strcmp(type, "Inverse Problem") == 0)) { - json_t *methodData = json_object_get(uqData,"bayesianCalibrationMethodData"); + json_t *methodData = json_object_get(uqData, "bayesianCalibrationMethodData"); - const char *method = json_string_value(json_object_get(methodData,"method")); + const char *method = json_string_value(json_object_get(methodData, "method")); /* const char *emulator = json_string_value(json_object_get(methodData,"emulator")); @@ -987,46 +1013,46 @@ writeDakotaInputFile(std::ostream &dakotaFile, emulatorString = "sc"; */ - int chainSamples = json_integer_value(json_object_get(methodData,"chainSamples")); - int seed = json_integer_value(json_object_get(methodData,"seed")); - int burnInSamples = json_integer_value(json_object_get(methodData,"burnInSamples")); - int jumpStep = json_integer_value(json_object_get(methodData,"jumpStep")); + int chainSamples = json_integer_value(json_object_get(methodData, "chainSamples")); + int seed = json_integer_value(json_object_get(methodData, "seed")); + int burnInSamples = json_integer_value(json_object_get(methodData, "burnInSamples")); + int jumpStep = json_integer_value(json_object_get(methodData, "jumpStep")); // int maxIterations = json_integer_value(json_object_get(methodData,"maxIter")); // double tol = json_number_value(json_object_get(methodData,"tol")); const char *calFileName = json_string_value(json_object_get(methodData, "calibrationDataFile")); - if (strcmp(method,"DREAM")==0) { + if (strcmp(method, "DREAM") == 0) { - int chains = json_integer_value(json_object_get(methodData,"chains")); + int chains = json_integer_value(json_object_get(methodData, "chains")); dakotaFile << "environment \n tabular_data \n tabular_data_file = 'dakotaTab.out' \n\n"; dakotaFile << "method \n bayes_calibration dream " - << "\n chain_samples = " << chainSamples - << "\n chains = " << chains - << "\n jump_step = " << jumpStep - << "\n burn_in_samples = " << burnInSamples - << "\n seed = " << seed - << "\n calibrate_error_multipliers per_response"; + << "\n chain_samples = " << chainSamples + << "\n chains = " << chains + << "\n jump_step = " << jumpStep + << "\n burn_in_samples = " << burnInSamples + << "\n seed = " << seed + << "\n calibrate_error_multipliers per_response"; - dakotaFile << "\n scaling\n" << "\n"; + dakotaFile << "\n scaling\n" << "\n"; } else { - const char *mcmc = json_string_value(json_object_get(methodData,"mcmcMethod")); + const char *mcmc = json_string_value(json_object_get(methodData, "mcmcMethod")); std::string mcmcString("dram"); - if (strcmp(mcmc,"Delayed Rejection")==0) - mcmcString = "delayed_rejection"; - else if (strcmp(mcmc,"Adaptive Metropolis")==0) - mcmcString = "adaptive_metropolis"; - else if (strcmp(mcmc,"Metropolis Hastings")==0) - mcmcString = "metropolis_hastings"; - else if (strcmp(mcmc,"Multilevel")==0) - mcmcString = "multilevel"; + if (strcmp(mcmc, "Delayed Rejection") == 0) + mcmcString = "delayed_rejection"; + else if (strcmp(mcmc, "Adaptive Metropolis") == 0) + mcmcString = "adaptive_metropolis"; + else if (strcmp(mcmc, "Metropolis Hastings") == 0) + mcmcString = "metropolis_hastings"; + else if (strcmp(mcmc, "Multilevel") == 0) + mcmcString = "multilevel"; dakotaFile << "environment \n tabular_data \n tabular_data_file = 'dakotaTab.out' \n\n"; dakotaFile << "method \n bayes_calibration queso\n " << mcmc - << "\n chain_samples = " << chainSamples - << "\n burn_in_samples = " << burnInSamples << "\n\n"; + << "\n chain_samples = " << chainSamples + << "\n burn_in_samples = " << burnInSamples << "\n\n"; } std::string calibrationString("BayesCalibration"); @@ -1041,20 +1067,20 @@ writeDakotaInputFile(std::ostream &dakotaFile, int numRVs = theRandomVariables.numRandomVariables; - json_t *methodData = json_object_get(uqData,"optimizationMethodData"); + json_t *methodData = json_object_get(uqData, "optimizationMethodData"); - const char *method = json_string_value(json_object_get(methodData,"method")); + const char *method = json_string_value(json_object_get(methodData, "method")); std::string methodString("coliny_pattern_search"); bool gradientBool = false; bool hessianBool = false; - if (strcmp(method,"Derivative-Free Local Search")==0) + if (strcmp(method, "Derivative-Free Local Search") == 0) methodString = "coliny_pattern_search"; - gradientBool = false; - hessianBool = false; + gradientBool = false; + hessianBool = false; - int maxIterations = json_integer_value(json_object_get(methodData,"maxIterations")); - double tol = json_number_value(json_object_get(methodData,"convergenceTol")); + int maxIterations = json_integer_value(json_object_get(methodData, "maxIterations")); + double tol = json_number_value(json_object_get(methodData, "convergenceTol")); double contractionFactor = json_number_value(json_object_get(methodData, "contractionFactor")); double initialDelta = json_number_value(json_object_get(methodData, "initialDelta")); int maxFunEvals = json_integer_value(json_object_get(methodData, "maxFunEvals")); @@ -1064,15 +1090,15 @@ writeDakotaInputFile(std::ostream &dakotaFile, dakotaFile << "environment \n tabular_data \n tabular_data_file = 'dakotaTab.out' \n\n"; - dakotaFile << "method, \n " << methodString - << "\n contraction_factor = " << contractionFactor - << "\n convergence_tolerance = " << tol - << "\n initial_delta = " << initialDelta - << "\n max_function_evaluations = " << maxFunEvals - << "\n max_iterations = " << maxIterations - << "\n total_pattern_size = " << 2*numRVs - << "\n variable_tolerance = " << thresholdDelta; - // << "\n solution_target = " << solutionTarget + dakotaFile << "method, \n " << methodString + << "\n contraction_factor = " << contractionFactor + << "\n convergence_tolerance = " << tol + << "\n initial_delta = " << initialDelta + << "\n max_function_evaluations = " << maxFunEvals + << "\n max_iterations = " << maxIterations + << "\n total_pattern_size = " << 2 * numRVs + << "\n variable_tolerance = " << thresholdDelta; + // << "\n solution_target = " << solutionTarget // if (strcmp(factors,"") != 0) dakotaFile << "\n scaling\n";