void CGridDlg::resetControls() { setNotifyEnabled(false); const GridParameters &v = getStartValue(); setCurrentValue(v); valueToWindow(v); setNotifyEnabled(true); }
BOOL CGridDlg::OnInitDialog() { __super::OnInitDialog(); m_accelTable = LoadAccelerators(theApp.m_hInstance,MAKEINTRESOURCE(IDR_PEARLGRID)); const GridParameters ¶m = getStartValue(); valueToWindow(param); PostMessage(ID_MSG_WINDOWTOTOP); return FALSE; }
MIMO::Ptr MotionProfileTrapezoidal::clone() { MotionProfileTrapezoidal::Ptr tmp = boost::make_shared< MotionProfileTrapezoidal > (); tmp->setProgressExpression( getProgressExpression()->clone() ); for (int i=0;i<nrOfOutputs();++i) { tmp->addOutput( getStartValue(i)->clone(), getEndValue(i)->clone(), getMaxVelocity(i)->clone(), getMaxAcceleration(i)->clone() ); } return tmp; }
short ElemDDLSGOptions::genSGA(SequenceGeneratorAttributes &sga) { sga.setSGStartValue(getStartValue()); sga.setSGIncrement(getIncrement()); sga.setSGMinValue(getMinValue()); sga.setSGMaxValue(getMaxValue()); sga.setSGCache(getCache()); sga.setSGCycleOption(isCycle()); sga.setSGFSDataType(getFSDataType()); sga.setSGResetOption(isReset()); return 0; }
void CGridDlg::OnCancel() { const GridParameters &v = getStartValue(); valueToWindow(v); setCurrentValue(v); OnHideWindow(); }
typename Population<FITNESS_TYPE>::chromosome_container SmoothPeakMutationOperation<VALUE_TYPE, FITNESS_TYPE>::doMutate( const typename Population<FITNESS_TYPE>::chromosome_container &chromosomeInputContainer, BaseManager<FITNESS_TYPE> &manager) const { typename Population<FITNESS_TYPE>::chromosome_container resultset; typename Population<FITNESS_TYPE>::chromosome_container choosenChromosomeContainer; typename Population<FITNESS_TYPE>::chromosome_container notChoosenChromosomeContainer; const auto maxNumMvc = this->getBuilderFactory().getSettings().getNum(); const auto continousBuilderSettings = ( static_cast<const ContinousMultiValueBuilderSettings<VALUE_TYPE, FITNESS_TYPE>&>(this->getBuilderFactory().getSettings()) ); choosenChromosomeContainer = this->getChoosingOperation().doChoose(chromosomeInputContainer); for(auto it: chromosomeInputContainer) { auto result = std::find(std::begin(choosenChromosomeContainer), std::end(choosenChromosomeContainer), it); if (result == std::end(choosenChromosomeContainer)) { notChoosenChromosomeContainer.emplace_back(it); } } //only mutate choosen chromosomes for (const auto &chosenChromosome : choosenChromosomeContainer) { const auto slotsToMutate = Random::generate<unsigned int>(this->getSettings().getMinimumPointsToMutate(), this->getSettings().getMaximumPointsToMutate()); //casting mutant to MVC const auto mvcMutant = std::dynamic_pointer_cast < MultiValueChromosome<VALUE_TYPE, FITNESS_TYPE> > (chosenChromosome); assert(mvcMutant); //creating a new MVC (to keep things reversible) auto mutatedChromosome = std::dynamic_pointer_cast < MultiValueChromosome<VALUE_TYPE, FITNESS_TYPE> > (this->getBuilderFactory().createChromosome(BaseChromosomeFactory<FITNESS_TYPE>::LET_UNPOPULATED)); assert(mutatedChromosome); //getting values const auto &mutantChromosomeContainer = mvcMutant->getContainer(); auto &result_container = mutatedChromosome->getContainer(); std::copy(mutantChromosomeContainer.cbegin(), mutantChromosomeContainer.cend(), result_container.begin()); //Predetermine Positions for Mutation: std::unordered_set<unsigned int> positions; while (positions.size() < slotsToMutate) { const auto rand = Random::generate<unsigned int>(0, maxNumMvc - 1); positions.emplace(rand); } //We have an predetermined amount of points for introducing peaks... for (const auto pos : positions) { const int sign = (Random::generateBit()) ? -1 : 1; const auto peak = sign * Random::generate<VALUE_TYPE>(0, this->_maxElevation); Smoothing::peakAt<VALUE_TYPE, FITNESS_TYPE>(pos, Random::generate<int>(0, this->_maxLeftEps), Random::generate<int>(0, this->_maxRightEps), //TODO(bewo): Make minElevation another setting peak, mutatedChromosome); } //Correct smoothness in mutated chromosome Smoothing::restoreSmoothness<VALUE_TYPE, FITNESS_TYPE>(mutatedChromosome, continousBuilderSettings.getEps(), continousBuilderSettings.getRandomMin(), continousBuilderSettings.getRandomMax(), continousBuilderSettings.hasStart(), continousBuilderSettings.getStartValue()); //Age reset mutatedChromosome->setAge(0); resultset.emplace_back(mutatedChromosome); } //add not mutated chromosomes resultset.insert(resultset.end(), notChoosenChromosomeContainer.begin(), notChoosenChromosomeContainer.end()); return resultset; }
NATraceList ElemDDLSGOptions::getDetailInfo() const { NAString detailText; NATraceList detailTextList; detailTextList.append("Sequence Generator Options:"); detailText = " SG Type: "; if (isInternalSG()) detailText = "INTERNAL "; else if (isExternalSG()) detailText = "EXTERNAL "; else detailText = "UNKNOWN "; detailTextList.append(detailText); detailText = " Start Value specified? "; detailText += YesNo(isStartValueSpecified()); detailTextList.append(detailText); detailText = " Start Value: "; detailText += Int64ToNAString(getStartValue()); detailTextList.append(detailText); detailText = " Increment specified? "; detailText += YesNo(isIncrementSpecified()); detailTextList.append(detailText); detailText = " Increment: "; detailText += Int64ToNAString(getIncrement()); detailTextList.append(detailText); detailText = " MaxValue specified? "; detailText += YesNo(isMaxValueSpecified()); detailTextList.append(detailText); if (isNoMaxValue()) { detailText = " Max Value: NO MAXVAL "; detailTextList.append(detailText); } else { detailText = " Max Value: "; detailText += Int64ToNAString(getMaxValue()); detailTextList.append(detailText); } detailText = " MinValue specified? "; detailText += YesNo(isMinValueSpecified()); detailTextList.append(detailText); if (isNoMinValue()) { detailText = " Min Value: NO MINVAL "; detailTextList.append(detailText); } else { detailText = " Min Value: "; detailText += Int64ToNAString(getMinValue()); detailTextList.append(detailText); } detailText = " Cycle specified? "; detailText += YesNo(isCycleSpecified()); detailTextList.append(detailText); if (isNoCycle()) { detailText = " Cycle Option: NO CYCLE "; detailTextList.append(detailText); } else { detailText = " Cycle Option: CYCLE "; detailTextList.append(detailText); } detailText = " Cache specified? "; detailText += YesNo(isCacheSpecified()); detailTextList.append(detailText); if (isNoCache()) { detailText = " Cache Option: NO CACHE "; detailTextList.append(detailText); } else { detailText = " Cache Option: CACHE "; detailTextList.append(detailText); } return detailTextList; }
// queryType: 0, create sequence. 1, alter sequence. 2, IDENTITY col. short ElemDDLSGOptions::validate(short queryType) { char queryTypeStr[40]; if (queryType == 0) strcpy(queryTypeStr, "CREATE SEQUENCE"); else if (queryType == 1) strcpy(queryTypeStr, "ALTER SEQUENCE"); else strcpy(queryTypeStr, "IDENTITY column"); Int64 minValue = 0; Int64 startValue = 0; Int64 increment = 0; Int64 maxValue = LONG_MAX - 1; NAString dtStr; if (fsDataType_ != COM_UNKNOWN_FSDT) { switch (fsDataType_) { case COM_UNSIGNED_BIN16_FSDT: maxValue = USHRT_MAX; dtStr = COM_SMALLINT_UNSIGNED_SDT_LIT; break; case COM_UNSIGNED_BIN32_FSDT: maxValue = UINT_MAX; dtStr = COM_INTEGER_UNSIGNED_SDT_LIT; break; case COM_SIGNED_BIN64_FSDT: maxValue = LONG_MAX - 1; dtStr = COM_LARGEINT_SIGNED_SDT_LIT; break; default: *CmpCommon::diags() << DgSqlCode(-1510); return -1; } } if (queryType == 1) // alter { if ((isMinValueSpecified()|| isStartValueSpecified())) { *CmpCommon::diags() << DgSqlCode(-1592) << (isMinValueSpecified() ? DgString0("MINVALUE") : DgString0("START WITH")) << DgString1(queryTypeStr); return -1; } minValue = getMinValue(); startValue = getStartValue(); increment = getIncrement(); if (isMaxValueSpecified() && (NOT isNoMaxValue())) { if ((fsDataType_ != COM_UNKNOWN_FSDT) && (getMaxValue() > maxValue)) { *CmpCommon::diags() << DgSqlCode(-1576) << DgString0("MAXVALUE") << DgString1(dtStr); return -1; } } maxValue = getMaxValue(); } // alter else { if (isResetSpecified()) { *CmpCommon::diags() << DgSqlCode(-1592) << DgString0("RESET") << DgString1(queryTypeStr); return -1; } minValue = ((isMinValueSpecified() && (NOT isNoMinValue())) ? getMinValue() : 1LL); startValue = (isStartValueSpecified() ? getStartValue() : minValue); increment = (isIncrementSpecified() ? getIncrement() : 1LL); } //else if (isMaxValueSpecified() && (NOT isNoMaxValue())) { if ((fsDataType_ != COM_UNKNOWN_FSDT) && (getMaxValue() > maxValue)) { *CmpCommon::diags() << DgSqlCode(-1576) << DgString0("MAXVALUE") << DgString1(dtStr); return -1; } maxValue = getMaxValue(); } if (minValue == 0) { *CmpCommon::diags() << DgSqlCode(-1571) << DgString0("MINVALUE") << DgString1(queryTypeStr); return -1; } if (minValue < 0) { *CmpCommon::diags() << DgSqlCode(-1572) << DgString0("MINVALUE") << DgString1(queryTypeStr); return -1; } if (maxValue == 0) { *CmpCommon::diags() << DgSqlCode(-1571) << DgString0("MAXVALUE") << DgString1(queryTypeStr); return -1; } if (maxValue < 0) { *CmpCommon::diags() << DgSqlCode(-1572) << DgString0("MAXVALUE") << DgString1(queryTypeStr); return -1; } if (increment == 0) { *CmpCommon::diags() << DgSqlCode(-1571) << DgString0("INCREMENT BY") << DgString1(queryTypeStr); return -1; } if (increment < 0) { *CmpCommon::diags() << DgSqlCode(-1572) << DgString0("INCREMENT BY") << DgString1(queryTypeStr); return -1; } if (startValue < 0) { *CmpCommon::diags() << DgSqlCode(-1572) << DgString0("START WITH") << DgString1(queryTypeStr); return -1; } if (maxValue <= minValue) { *CmpCommon::diags() << DgSqlCode(-1570) << DgString0(queryTypeStr); return -1; } if (startValue > maxValue) { *CmpCommon::diags() << DgSqlCode(-1573) << DgString0(queryTypeStr); return -1; } if (startValue < minValue) { *CmpCommon::diags() << DgSqlCode(-1573) << DgString0(queryTypeStr); return -1; } if (increment > (maxValue - minValue)) { *CmpCommon::diags() << DgSqlCode(-1575) << DgString0(queryTypeStr); return -1; } Int64 cache = 0; Int64 minVal = MAXOF(startValue, minValue); Int64 rangeOfVals = (maxValue-minVal)/increment + 1; if (isCacheSpecified()) cache = getCache(); else cache = MINOF(rangeOfVals, 25); if (NOT isNoCache()) { if ((cache <= 1) || (cache > rangeOfVals)) { *CmpCommon::diags() << DgSqlCode(-1577) << DgString0(queryTypeStr); return -1; } } cache = MINOF(rangeOfVals, cache); setStartValue(startValue); setIncrement(increment); setMinValue(minValue); setMaxValue(maxValue); if (NOT isCacheSpecified()) setCache(cache); return 0; }