CalibrationUtilityBill::CalibrationUtilityBill(const std::string& name, const FuelType& fuelType, const InstallLocationType& meterInstallLocation,
    boost::optional<std::string> meterSpecificInstallLocation, boost::optional<EndUseCategoryType> meterEndUseCategory, 
    boost::optional<std::string> meterSpecificEndUse, std::string consumptionUnit, double consumptionUnitConversionFactor,
    boost::optional<std::string> peakDemandUnit, boost::optional<double> peakDemandUnitConversionFactor,
    boost::optional<unsigned> timestepsInPeakDemandWindow, boost::optional<double> minutesInPeakDemandWindow,
    boost::optional<unsigned> numberBillingPeriodsInCalculations, boost::optional<double> CVRMSE, boost::optional<double> NMBE)
    : m_attribute(CalibrationUtilityBill::attributeName(), std::vector<openstudio::Attribute>(), boost::none)
  {
    std::vector<Attribute> values;

    values.push_back(Attribute("name", name));
    values.push_back(Attribute("fuelType", fuelType.valueName()));
    values.push_back(Attribute("meterInstallLocation", meterInstallLocation.valueName()));
    if (meterSpecificInstallLocation){
      values.push_back(Attribute("meterSpecificInstallLocation", *meterSpecificInstallLocation));
    }
    if (meterEndUseCategory){
      values.push_back(Attribute("meterEndUseCategory", meterEndUseCategory->valueName()));
    }
    if (meterSpecificEndUse){
      values.push_back(Attribute("meterSpecificEndUse", *meterSpecificEndUse));
    }
    values.push_back(Attribute("consumptionUnit", consumptionUnit));
    values.push_back(Attribute("consumptionUnitConversionFactor", consumptionUnitConversionFactor));
    if (peakDemandUnit){
      values.push_back(Attribute("peakDemandUnit", *peakDemandUnit));
    }
    if (peakDemandUnitConversionFactor){
      values.push_back(Attribute("peakDemandUnitConversionFactor", *peakDemandUnitConversionFactor));
    }
    if (timestepsInPeakDemandWindow){
      values.push_back(Attribute("timestepsInPeakDemandWindow", *timestepsInPeakDemandWindow));
    }
    if (minutesInPeakDemandWindow){
      values.push_back(Attribute("minutesInPeakDemandWindow", *minutesInPeakDemandWindow));
    }
    if (numberBillingPeriodsInCalculations){
      values.push_back(Attribute("numberBillingPeriodsInCalculations", *numberBillingPeriodsInCalculations));
    }
    if (CVRMSE){
      values.push_back(Attribute("cvrmse", *CVRMSE));
    }
    if (NMBE){
      values.push_back(Attribute("nmbe", *NMBE));
    }

    values.push_back(Attribute("billingPeriods", std::vector<Attribute>()));

    m_attribute.setValue(values);
  }