GeneticAlgorithm::GeneticAlgorithm(double* dataSet, int dataSetLength,  int nPopulation, double scaleFactor, double crossingProbability, int order, double xHL, double yHL, double zHL, double density, int nMissing){	
	
	totalTime = 0;  // for timing things
		
	QueryPerformanceFrequency(&freq);

	_nPopulation = nPopulation;
	initializeRandomNumberGenerators();
	
	_nMissing = nMissing;
	_order = order;
	_R = 3 * (order+1) * (order+2) * (order+3) / 6;

	_xHL = xHL;
	_yHL = yHL;
	_zHL = zHL;

	_density = density;
	_basisPop = new int[8];
	for(int i = 0; i < 8; i++){
		_basisPop[i] = 0;
	}
	
	_basis = createBasis(order, _basisPop);

	initialiseMatrices();

	initializeParameters(dataSet, dataSetLength, nPopulation, scaleFactor, crossingProbability);	

	
	
}
Example #2
0
OutputInfo FullyConnected::initialize(std::vector<double*>& parameterPointers,
                                      std::vector<double*>& parameterDerivativePointers)
{
  parameterPointers.reserve(parameterPointers.size() + J * (I + bias));
  parameterDerivativePointers.reserve(parameterDerivativePointers.size() + J * (I + bias));
  for(int j = 0; j < J; j++)
  {
    for(int i = 0; i < I; i++)
    {
      parameterPointers.push_back(&W(j, i));
      parameterDerivativePointers.push_back(&Wd(j, i));
    }
    if(bias)
    {
      parameterPointers.push_back(&b(j));
      parameterDerivativePointers.push_back(&bd(j));
    }
  }

  initializeParameters();

  OutputInfo info;
  info.dimensions.push_back(J);
  return info;
}
Example #3
0
MSAGeneralTab::MSAGeneralTab(MSAEditor* _msa)
    : msa(_msa), savableTab(this, GObjectViewUtils::findViewByName(_msa->getName()))
{
    SAFE_POINT(NULL != msa, "MSA Editor not defined.", );

    setupUi(this);

    ShowHideSubgroupWidget* alignmentInfo = new ShowHideSubgroupWidget("ALIGNMENT_INFO", tr("Alignment info"), alignmentInfoWidget, true);
    ShowHideSubgroupWidget* consensusMode = new ShowHideSubgroupWidget("CONSENSUS_MODE", tr("Consensus mode"), consensusModeWidget, true);
    ShowHideSubgroupWidget* copyType = new ShowHideSubgroupWidget("COPY_TYPE", tr("Copy to clipboard"), copyTypeWidget, true);
    Ui_GeneralTabOptionsPanelWidget::layout->addWidget(alignmentInfo);
    Ui_GeneralTabOptionsPanelWidget::layout->addWidget(consensusMode);
    Ui_GeneralTabOptionsPanelWidget::layout->addWidget(copyType);

    initializeParameters();
    connectSignals();

    U2WidgetStateStorage::restoreWidgetState(savableTab);

#ifdef Q_OS_MAC
    copyButton->setToolTip("Cmd+Shift+C");
#else
    copyButton->setToolTip("Ctrl+Shift+C");
#endif

}
Example #4
0
ScopLib::ScopLib(Scop *S) : PollyScop(S) {
  scoplib = scoplib_scop_malloc();

  initializeArrays();
  initializeParameters();
  initializeScattering();
  initializeStatements();
}
returnValue OptimizationAlgorithmBase::initializeParameters( const char* fileName)
{
	VariablesGrid tmp = fopen( fileName,"r" );
	
	if ( tmp.isEmpty() == BT_TRUE )
		return RET_FILE_CAN_NOT_BE_OPENED;
	
    return initializeParameters(tmp);
}
Example #6
0
File: master.cpp Project: ogdf/ogdf
void Master::_initializeParameters()
{
	// Master::_initializeParameters(): local variables
	/* The function \a _initializeLpParameters() initializes the LP solver
	*   specific Parameters. It is called after the parameter-file
	*   {\tt .abacus} was read and all general parameters were processed.
	*
	*   This function is implemented in the file \a lpif.cc.
	*/

	if(readParamFromFile_) {
		// set up the name of the configuration file
		// The location of the configuration file .abacus is given by the environment variable ABACUS_DIR.
		char *abacusDir = getenv("ABACUS_DIR");
		if (!abacusDir) {
			Logger::ifout() << "environment variable ABACUS_DIR not found\n";
			OGDF_THROW_PARAM(AlgorithmFailureException, ogdf::AlgorithmFailureCode::IllegalParameter);
		}

#ifdef OGDF_SYSTEM_UNIX
		string configFileName = string(abacusDir) + "/.abacus";
#else
		string configFileName = string(abacusDir) + "\\.abacus";
#endif

		readParameters(configFileName);

	} else {

		// set default values for abacus parameters
		insertParameter("EnumerationStrategy","BestFirst");
		insertParameter("BranchingStrategy","CloseHalfExpensive");
		insertParameter("NBranchingVariableCandidates","1");
		insertParameter("NStrongBranchingIterations","50");
		insertParameter("Guarantee","0.0");
		insertParameter("MaxLevel","999999");
		insertParameter("MaxNSub","9999999");
		insertParameter("MaxCpuTime","99999:59:59");
		insertParameter("MaxCowTime","99999:59:59");
		insertParameter("ObjInteger","false");
		insertParameter("TailOffNLps","0");
		insertParameter("TailOffPercent","0.0001");
		insertParameter("DelayedBranchingThreshold","0");
		insertParameter("MinDormantRounds","1");
		insertParameter("PrimalBoundInitMode","None");
		insertParameter("PricingFrequency","0");
		insertParameter("SkipFactor","1");
		insertParameter("SkippingMode","SkipByNode");
		insertParameter("FixSetByRedCost","true");
		insertParameter("PrintLP","false");
		insertParameter("MaxConAdd","100");
		insertParameter("MaxConBuffered","100");
		insertParameter("MaxVarAdd","500");
		insertParameter("MaxVarBuffered","500");
		insertParameter("MaxIterations","-1");
		insertParameter("EliminateFixedSet","false");
		insertParameter("NewRootReOptimize","false");
		insertParameter("ShowAverageCutDistance","false");
		insertParameter("ConstraintEliminationMode","Basic");
		insertParameter("ConElimEps","0.001");
		insertParameter("ConElimAge","1");
		insertParameter("VariableEliminationMode","ReducedCost");
		insertParameter("VarElimEps","0.001");
		insertParameter("VarElimAge","1");
		insertParameter("VbcLog","None");
#if defined(COIN_OSI_CPX)
	insertParameter("DefaultLpSolver","CPLEX");
#elif defined(COIN_OSI_SYM)
	insertParameter("DefaultLpSolver","SYMPHONY");
#elif defined(COIN_OSI_GRB)
	insertParameter("DefaultLpSolver","Gurobi");
#else
		insertParameter("DefaultLpSolver","Clp");
#endif
		insertParameter("SolveApprox","false");

		_setDefaultLpParameters();
	}

	// let the user set/overwrite parameters in 4 steps.
	// 1) Assign parameters that were read from the global abacus config file
	assignParameters();

	// 2) Allow user to read parameters from custom config file
	initializeParameters();

	// 3) Assign parameters from custom config file.
	// this assigns all parameters that were read from the abacus config file
	// in the abacus directory and those that the user read from a file
	// in initializeParameters(). However, this will overwrite any parameter
	// that was set directly.
	assignParameters();

	// 4) Allow user to set parameters directly
	// call initializeParameters again so that parameters that were set directly
	// (and not via a config file) can be set (undo the overwrite from step 2).
	// Since we do *not* call assignParameters again, those parameters are not
	// overwritten this time.
	initializeParameters();

	_initializeLpParameters();
}
GeneticAlgorithm2::GeneticAlgorithm2(double** dataSet, int dataSetLength,  int nPopulation, double scaleFactor, double crossingProbability){	
	QueryPerformanceFrequency(&freq);
	_nPopulation = nPopulation;
	initializeRandomNumberGenerators();
	initializeParameters(dataSet, dataSetLength, nPopulation, scaleFactor, crossingProbability);	
}
Example #8
0
OutputInfo Subsampling::initialize(std::vector<double*>& parameterPointers,
                                   std::vector<double*>& parameterDerivativePointers)
{
  OutputInfo info;
  info.dimensions.push_back(fm);
  outRows = inRows / kernelRows;
  outCols = inCols / kernelCols;
  fmOutSize = outRows * outCols;
  info.dimensions.push_back(outRows);
  info.dimensions.push_back(outCols);
  fmInSize = inRows * inCols;
  maxRow = inRows - kernelRows + 1;
  maxCol = inCols - kernelCols + 1;

  W.resize(fm, Eigen::MatrixXd(outRows, outCols));
  Wd.resize(fm, Eigen::MatrixXd(outRows, outCols));
  int numParams = fm * outRows * outCols * kernelRows * kernelCols;
  if(bias)
  {
    Wb.resize(fm, Eigen::MatrixXd(outRows, outCols));
    Wbd.resize(fm, Eigen::MatrixXd(outRows, outCols));
    numParams += fm * outRows * outCols;
  }
  parameterPointers.reserve(parameterPointers.size() + numParams);
  parameterDerivativePointers.reserve(parameterDerivativePointers.size() + numParams);
  for(int fmo = 0; fmo < fm; fmo++)
  {
    for(int r = 0; r < outRows; r++)
    {
      for(int c = 0; c < outCols; c++)
      {
        parameterPointers.push_back(&W[fmo](r, c));
        parameterDerivativePointers.push_back(&Wd[fmo](r, c));
        if(bias)
        {
          parameterPointers.push_back(&Wb[fmo](r, c));
          parameterDerivativePointers.push_back(&Wbd[fmo](r, c));
        }
      }
    }
  }

  initializeParameters();

  a.resize(1, info.outputs());
  y.resize(1, info.outputs());
  yd.resize(1, info.outputs());
  deltas.resize(1, info.outputs());

  if(info.outputs() < 1)
    throw OpenANNException("Number of outputs in subsampling layer is below"
                           " 1. You should either choose a smaller filter"
                           " size or generate a bigger input.");
  OPENANN_CHECK(fmInSize > 0);
  OPENANN_CHECK(outRows > 0);
  OPENANN_CHECK(outCols > 0);
  OPENANN_CHECK(fmOutSize > 0);
  OPENANN_CHECK(maxRow > 0);
  OPENANN_CHECK(maxCol > 0);

  return info;
}
Example #9
0
bool Jpeg2000::load (const QString &filename,
                     QImage &imageResult) const
{
  LOG4CPP_INFO_S ((*mainCat)) << "Jpeg2000::load"
                              << " filename=" << filename.toLatin1().data();

  if (invalidFileExtension (filename)) {
    return false;
  }

  opj_dparameters_t parameters;
  initializeParameters (parameters);

  parameters.decod_format = inputFormat (filename.toLatin1().data());

  opj_stream_t *inStream = opj_stream_create_default_file_stream (filename.toLatin1().data(), 1);
  if (!inStream) {
    LOG4CPP_ERROR_S ((*mainCat)) << "Jpeg2000::load encountered error opening stream";
    return false;
  }

  // Create decoder
  opj_codec_t *inCodec = decode (parameters.decod_format);
  if (!inCodec) {
    LOG4CPP_ERROR_S ((*mainCat)) << "Jpeg2000::load encountered error creating decoding stream";
    opj_stream_destroy (inStream);
    return false;
  }

  // Callbacks for local handling of errors
  opj_set_info_handler (inCodec, infoCallback, 0);
  opj_set_warning_handler (inCodec, warningCallback, 0);
  opj_set_error_handler (inCodec, errorCallback, 0);

  if (!opj_setup_decoder (inCodec,
                          &parameters)) {
    LOG4CPP_ERROR_S ((*mainCat)) << "Jpeg2000::load encountered error decoding stream";
    opj_stream_destroy (inStream);
    opj_destroy_codec (inCodec);
    return false;
  }

  // Read header and, if necessary, the JP2 boxes
  opj_image_t *image;
  if (!opj_read_header (inStream,
                        inCodec,
                        &image)) {
    LOG4CPP_ERROR_S ((*mainCat)) << "Jpeg2000::load encountered error reading header";
    opj_stream_destroy (inStream);
    opj_destroy_codec (inCodec);
    opj_image_destroy (image);
    return false;
  }

  // Get the decoded image
  if (!(opj_decode (inCodec,
                    inStream,
                    image) &&
       opj_end_decompress (inCodec,
                           inStream))) {
    LOG4CPP_ERROR_S ((*mainCat)) << "Jpeg2000::load failed to decode image";
    opj_destroy_codec (inCodec);
    opj_stream_destroy (inStream);
    opj_image_destroy (image);
    return false;
  }

  // Close the byte stream
  opj_stream_destroy (inStream);

  applyImageTweaks (image);

  // Transform into ppm image in memory
  bool success = true;
  QBuffer buffer;
  buffer.open (QBuffer::WriteOnly);
  if (imagetopnm (image,
                  buffer)) {
    LOG4CPP_ERROR_S ((*mainCat)) << "Jpeg2000::load failed to generate new image";
    success = false;

  } else {

    // Intermediate file for debugging
//    QFile file ("jpeg2000.ppm");
//    file.open (QIODevice::WriteOnly);
//    file.write (buffer.data());
//    file.close ();

    // Create output
    imageResult.loadFromData(buffer.data());

  }

  // Deallocate
  if (inCodec) {
    opj_destroy_codec (inCodec);
  }
  opj_image_destroy (image);

  return success;
}
Example #10
0
void S2Controller::initializeS2(){
    initializeParameters();
    connectToS2();
}