Esempio n. 1
0
BddNodeHandle BddManager::restrict(BddNodeHandle pFst, BddNodeHandle pSnd) {
    if (pSnd == BDD_TRUE || pFst->isTerminal())
        return pFst;
    
    if (pSnd == BDD_FALSE)
        return BDD_FALSE;

    if (pFst == pSnd)
        return pFst;

    if (pFst == makeNeg(pSnd))
        return BDD_FALSE;

    int topVar = max(pFst->getCurDecisionLevel(), pSnd->getCurDecisionLevel());


    BddNodeHandle fp = pFst->getPosCofactor(pFst, topVar);
    BddNodeHandle fn = pFst->getNegCofactor(pFst, topVar);

    BddNodeHandle gp = pSnd->getPosCofactor(pSnd, topVar);
    BddNodeHandle gn = pSnd->getNegCofactor(pSnd, topVar);

    if (gp == BDD_FALSE)
        return restrict(fn, gn);
    if (gn == BDD_FALSE)
        return restrict(fp, gp);
    if (topVar != pFst->getCurDecisionLevel())
        return restrict(pFst, ite(gp, BDD_TRUE, gn));
    return ite(makeBddNode(topVar), restrict(fp, gp), restrict(fn, gn));
}
Esempio n. 2
0
CdFilenameStr& CdFilenameStr::setFilename( std::wstring ev ) 
{
	CStrCharSizeMb	ite( ev ) ;
	int	iBidx ;
	for ( iBidx = ite.BidxLast() ; iBidx >  0 ; iBidx = ite.BidxNextChar( iBidx , -1 ) ) {
		if ( ite.CsizeOfBidx( iBidx ) == 1 ){
			if ( ev[iBidx] == '.' ) {
				break ;	//	iExtPeriod = 拡張子の前の'.'のインデクスです。
			}
			if ( ev[iBidx]  == '\\' || ev[iBidx]  == ':' ){
				iBidx = -1 ;
				break ;
					//iBidx = -1は拡張子がみつからなかったことを示します。
			}
		}
	}
	//iBidx = 拡張子の前の'.'のインデクスです。
	//	みつからなければ-1です
	if ( iBidx > 0 ){
		m_strBaseFilename = ev.substr( 0 , iBidx ) ; 
		m_strExtension    = ev.substr( iBidx + 1 ) ; 
	}	else	{
		m_strBaseFilename = ev ;
		m_strExtension.erase() ;
	}
	return ( *this ) ;
}
Esempio n. 3
0
bool TeX2img::Download(HWND hwnd,MSGFUNC &msgfunc){
	msgfunc.msg(_T("TeX2img のファイルを探索\n"));
	std::wregex reg;
	try{reg.assign(m_filereg,std::regex_constants::icase);}
	catch(...){
		msgfunc.detail(_T("TeX2img の発見に失敗\n"));
		g_Setting.Log(_T("TeX2img を発見する正規表現が不正です."));
		return false;
	}
	boost::filesystem::directory_iterator end;
	try{
		for(boost::filesystem::directory_iterator ite(m_filedir) ; ite != end ; ++ite){
			boost::filesystem::path p(*ite);
			if(std::regex_match(p.filename().wstring(),reg)){
				m_file = p.filename().wstring();
				break;
			}
		}
	}
	catch(...){
		g_Setting.Log(_T("TeX2img を保存しているフォルダが見つかりませんでした."));
		return false;
	}
	if(m_file == _T("")){
		msgfunc.detail(_T("TeX2img の発見に失敗\n"));
		g_Setting.Log(_T("TeX2img が見つかりませんでした."));
		return false;
	}else return true;
}
void CMV_BookManager::updateBookDatabase()
{
    QString path = "book.db";
    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", "db");
    db.setDatabaseName(path);
    if (!db.open()){
        qDebug()<<"An error occurred while opening the connection: "<< db.lastError().text();
        return;
    }
    QSqlQuery q("", db);
    q.exec("create table Books (id integer primary key, path TEXT)");

    int i = 0;
    QDirIterator ite("/", QDirIterator::Subdirectories);

    while (ite.hasNext()){
        auto inf = ite.fileInfo();
        if(inf.isFile() && (!QString::compare(QStringLiteral("CBZ"), inf.suffix(),
                                              Qt::CaseInsensitive))){
            q.exec(QStringLiteral("insert into Books values (%1, '%2')").arg(QString::number(i++),inf.absoluteFilePath()));


        }
        ite.next();
    }
}
Esempio n. 5
0
        QString D3_Hero::toString() const
        {
            QString strReturn;
            strReturn += m_strName;
            strReturn += "; " + QString::number( m_iID );
            strReturn += "; " + QString::number( m_iLevel );
            strReturn += "; " + QString( ( m_bHardcore ? "Hardcore" : "Softcore" ) );
            strReturn += "; " + QString::number( m_iParagonLvl );
            strReturn += "; " + QString::number( m_iGender );
            strReturn += "; " + QString( ( m_bDead ? "Dead" : "Alive" ) );
            strReturn += "; " + m_strClass;
            strReturn += "; " + QString::number( m_iLastUpdated );

            if( NULL != m_pSkillContainer )
            {
                strReturn += "; " + m_pSkillContainer->toString();
            }

            if( NULL != m_pStats )
            {
                strReturn += "; " + m_pStats->toString();
            }

            strReturn   += "\nItems : \n{ ";
            QHashIterator< uint, D3_Item* > ite( m_hItems );
            while( ite.hasNext() )
            {
                ite.next();
                strReturn += "\n\t" + ite.value()->toString() + ";";
            }
            strReturn   += "\n}";

            return strReturn;
        }
Esempio n. 6
0
void THashTest::TestHMMap1() {
    typedef yhash_multimap<char, int, THash<char>, TEqualTo<char> > mmap;
    mmap m;

    UNIT_ASSERT(m.count('X') == 0);
    m.insert(TPair<const char, int>('X', 10)); // Standard way.
    UNIT_ASSERT(m.count('X') == 1);

    m.insert(TPair<const char, int>('X', 20));  // jbuck: standard way
    UNIT_ASSERT(m.count('X') == 2);

    m.insert(TPair<const char, int>('Y', 32));  // jbuck: standard way
    mmap::iterator i = m.find('X'); // Find first match.

    UNIT_ASSERT((*i).first == 'X');
    UNIT_ASSERT((*i).second == 10);
    i++;
    UNIT_ASSERT((*i).first == 'X');
    UNIT_ASSERT((*i).second == 20);

    i = m.find('Y');
    UNIT_ASSERT((*i).first == 'Y');
    UNIT_ASSERT((*i).second == 32);

    i = m.find('Z');
    UNIT_ASSERT(i == m.end());

    size_t count = m.erase('X');
    UNIT_ASSERT(count == 2);

    //Some iterators compare check, really compile time checks
    mmap::iterator ite(m.begin());
    mmap::const_iterator cite(m.begin());

    UNIT_ASSERT((mmap::const_iterator)ite == cite);
    UNIT_ASSERT(!((mmap::const_iterator)ite != cite));
    UNIT_ASSERT(cite == (mmap::const_iterator)ite);
    UNIT_ASSERT(!(cite != (mmap::const_iterator)ite));

    typedef yhash_multimap<size_t, size_t> HMapType;
    HMapType hmap;

    //We fill the map to implicitely start a rehash.
    for (size_t counter = 0; counter < 3077; ++counter) {
        hmap.insert(HMapType::value_type(1, counter));
    }

    hmap.insert(HMapType::value_type(12325, 1));
    hmap.insert(HMapType::value_type(12325, 2));

    UNIT_ASSERT(hmap.count(12325) == 2);

    //At this point 23 goes to the same bucket as 12325, it used to reveal a bug.
    hmap.insert(HMapType::value_type(23, 0));

    UNIT_ASSERT(hmap.count(12325) == 2);
}
void NodeGraphicsScene::checkNoTextVisible()
{
	QListIterator<GraphicsNodeNoTextItem*> ite(mNodeNoTextItemList);
	GraphicsNodeNoTextItem * item;
	while (ite.hasNext())
	{
		item = ite.next();
		item->updateVisible();
	}

}
Esempio n. 8
0
BddNodeHandle BddManager::ite(BddNodeHandle pIf, BddNodeHandle pThen, BddNodeHandle pElse) {


    // !g = ite(g, 0, 1)
    if (pThen->isStructureEqual(BddNode::getConstZeroHandle()) && pElse ->isStructureEqual(BddNode::getConstOneHandle()))
        return makeNeg(pIf);

    // ite(A, B, C) = ite(!A, C, B)
#if 1

    // ite(f, g, 0)
    if (pElse->isStructureEqual(BddNode::getConstZeroHandle()))
        return makeAnd(pIf, pThen);
//        return apply(OP_AND, pIf, pThen);

    // ite(f, 0, g)
    if (pThen->isStructureEqual(BddNode::getConstZeroHandle())) {
        return ite(makeNeg(pIf), BddNode::getConstZeroHandle(), pElse);
    }

    // ite(f, 1, g)
    if (pThen->isStructureEqual(BddNode::getConstOneHandle())) {
        return makeNeg(ite(makeNeg(pIf), makeNeg(pElse), BddNode::getConstZeroHandle()));
    }
    
    // ite(f, g, 1)
    // ite(!f, 1, g)
    if (pElse->isStructureEqual(BddNode::getConstOneHandle())) {
        return ite(makeNeg(pIf), BddNode::getConstOneHandle(), pThen);
    }

    // ite(f, g, h) =
    //     fg + f'h
    //     ite(fg, 1, f'h)
#endif

    return ite( makeAnd(pIf, pThen)
              , BddNode::getConstOneHandle()
              , makeAnd(makeNeg(pIf), pElse));
}
void NodeGraphicsScene::updateItems()
{
	GraphicsScene::updateItems();
	QListIterator<GraphicsNodeItem*> ite(mNodeItemList);
	GraphicsNodeItem* item;
	while (ite.hasNext())
	{
		item = ite.next();
		item->setPos(item->nodeData()->sceneCoor());
	}
	mEdgeNetItem->advance();
	checkNoTextVisible();
}
Esempio n. 10
0
    bool generateEquations(std::vector<std::vector<z3::expr*> > &weights,
                           const LinkDescriptor &linkTable)
    {
        size_t i;
        size_t j;
        size_t totalSizeNode = _inputNodes.size() + _hiddenNodes.size() +
            _outputNodes.size();

        /* checking error of array size */
        if (weights.size() != totalSizeNode)
            {
                std::cerr << "Error: weight table not corresponding to number of nodes in Z3Equation" << std::endl;
                return false;
            }
        for (i = 0; i < weights.size(); ++i)
            if (weights[i].size() != totalSizeNode)
                {
                    std::cerr << "Error: weight table not corresponding to number of nodes in Z3Equation" << std::endl;
                    return false;
                }

        for (i = 0 ; i < totalSizeNode; ++i)
            {
                // build equation
                z3::expr tmp(_context.real_const("tmp"));
                bool b = true;
                for (j = 0; j < totalSizeNode; ++j)
                    {
                        if (linkTable.getLink(j, i))
                            {
                                if (b)
                                    {
                                        tmp = *(weights[j][i]) * *(getNode(j));
                                        b = false;
                                    }
                                else
                                    tmp = tmp + (*(weights[j][i]) * *(getNode(j)));
                            }

                    }
                // FIXME : improve activation function
                // sigmoid(&tmp) for instance;
                tmp = ite(tmp > TOINT((_min + (_max - _min) / 2.f), _precision),
			  _context.real_val(TOINT(_max, _precision)),
                          _context.real_val(TOINT(_min, _precision)));
                if (!b)
                    *getNode(i) = tmp;
            }
        return true;
    }
Esempio n. 11
0
void nforcepc_state::nforcepc(machine_config &config)
{
	athlonxp_device &maincpu(ATHLONXP(config, "maincpu", 90000000));
	maincpu.set_addrmap(AS_PROGRAM, &nforcepc_state::nforce_map);
	maincpu.set_addrmap(AS_IO, &nforcepc_state::nforce_map_io);
	maincpu.set_irq_acknowledge_callback(FUNC(nforcepc_state::irq_callback));
	//maincpu.smiact().set("pci:01.0", FUNC(i82439hx_host_device::smi_act_w));

	PCI_ROOT(config, ":pci", 0);
	CRUSH11(config, ":pci:00.0", 0, "maincpu", "bios"); // 10de:01a4 NVIDIA Corporation nForce CPU bridge
	CRUSH11_MEMORY(config, ":pci:00.1", 0, 2); /* 10de:01ac NVIDIA Corporation nForce 220/420 Memory Controller
	10de:01ad NVIDIA Corporation nForce 220/420 Memory Controller
	10de:01ab NVIDIA Corporation nForce 420 Memory Controller (DDR)*/
	mcpx_isalpc_device &isa(MCPX_ISALPC(config, ":pci:01.0", 0, 0x10430c11)); // 10de:01b2 NVIDIA Corporation nForce ISA Bridge (LPC bus)
	isa.smi().set_inputline(":maincpu", INPUT_LINE_SMI);
	isa.boot_state_hook().set(FUNC(nforcepc_state::boot_state_award_w));
	isa.interrupt_output().set(FUNC(nforcepc_state::maincpu_interrupt));
	it8703f_device &ite(IT8703F(config, ":pci:01.0:0", 0));
	ite.pin_reset().set_inputline(":maincpu", INPUT_LINE_RESET);
	ite.pin_gatea20().set_inputline(":maincpu", INPUT_LINE_A20);
	MCPX_SMBUS(config, ":pci:01.1", 0); // 10de:01b4 NVIDIA Corporation nForce PCI System Management (SMBus)
	SMBUS_ROM(config, ":pci:01.1:050", 0, test_spd_data, sizeof(test_spd_data)); // these 3 are on smbus number 0
	SMBUS_LOGGER(config, ":pci:01.1:051", 0);
	SMBUS_LOGGER(config, ":pci:01.1:052", 0);
	SMBUS_LOGGER(config, ":pci:01.1:108", 0); // these 4 are on smbus number 1
	AS99127F(config, ":pci:01.1:12d", 0);
	AS99127F_SENSOR2(config, ":pci:01.1:148", 0);
	AS99127F_SENSOR3(config, ":pci:01.1:149", 0);
	SST_49LF020(config, "bios", 0);
	/*10de:01c2 NVIDIA Corporation nForce USB Controller
	10de:01c2 NVIDIA Corporation nForce USB Controller
	10de:01b0 NVIDIA Corporation nForce Audio Processing Unit
	10de:01b1 NVIDIA Corporation nForce AC'97 Audio Controller
	10de:01b8 NVIDIA Corporation nForce PCI-to-PCI bridge
	10de:01bc NVIDIA Corporation nForce IDE
	10de:01b7 NVIDIA Corporation nForce AGP to PCI Bridge
	*/
	/* maincpu.smiact().set("pci:00.0", FUNC(i82439hx_host_device::smi_act_w));

	i82371sb_ide_device &ide(I82371SB_IDE(config, ":pci:07.1", 0));
	ide.irq_pri().set(":pci:07.0", FUNC(i82371sb_isa_device::pc_irq14_w));
	ide.irq_sec().set(":pci:07.0", FUNC(i82371sb_isa_device::pc_irq15_w));*/
}
Esempio n. 12
0
			uint64_t lookupValue(uint64_t const v) const
			{				
				if ( !index.size() )
					return 0;

				typedef IndexEntryValueGetAdapter<IndexEntry const *> adapter_type;
				adapter_type IEKGA(index.get());
				::libmaus::util::ConstIterator<adapter_type,uint64_t> const ita(&IEKGA);
				::libmaus::util::ConstIterator<adapter_type,uint64_t> ite(ita);
				ite += index.size();
				
				::libmaus::util::ConstIterator<adapter_type,uint64_t> R =
					::std::lower_bound(ita,ite,v);
					
				if ( R == ite )
					return index.size()-1;
					
				if ( v == *R )
					return R-ita;
				else
					return (R-ita)-1;
			}
Esempio n. 13
0
void ConsolePage::eeHistoryReplyFinished()
{
    QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());

    qDebug() << "eeHistoryReplyFinished()";
    QString data = (QString) reply->readAll();
    QScriptEngine engine;
    QScriptValue result = engine.evaluate("value = " + data);
    QScriptValueIterator ite(result);
    while(ite.hasNext()) {
         ite.next();
        //qDebug() << ite.name() << ": " << ite.value().toString();
    }

    // {"BLUNT-BTC":[{"type":"Buy","date":1415845314,"amount":"142.80000000","price":"0.00002400","total":"0.00342720"},{"type":"Buy","date":1415845120,"amount":"202.98107194","price":"0.00002199","total":"0.00446355"},

    QString tbl = "<b>EmpoEx BLUNT-BTC</b><br><br><table cellpadding=\"5\" width=\"100%\"><thead><tr><th>Type</th><th>Date</th><th>Amount</th><th>Price</th><th>Total</th></tr></thead>";

    // Now parse this JSON according to your needs !
    QScriptValue entries = result.property("BLUNT-BTC");
    QScriptValueIterator it(entries);

    tbl = tbl + "<tbody>";
    while (it.hasNext()) {
        it.next();
        QScriptValue entry = it.value();
        QString type = entry.property("type").toString();
    QString date = entry.property("date").toString();
        QString amount = QString::number(entry.property("amount").toNumber(), 'f', 8);
        QString price = QString::number(entry.property("price").toNumber(), 'f', 8);
        QString total = QString::number(entry.property("total").toNumber(), 'f', 8);

        tbl = tbl + "<tr><td>" + type + "</td><td>" + date + "</td><td>" + amount + "</td><td>" + price + "</td><td>" + total + "</td></tr>";
    }
    tbl = tbl + "</tbody></table>";
    qDebug() << "Returning market data table";
    message(CMD_REPLY, tbl, true);
}
Esempio n. 14
0
void EditToolBar::searchInCurrentActionsSlot(QString str)
{
    //user search
    searchMade = true;

    //check if str isn't empty
    if(str.isEmpty()){
        this->fillCurrentItemsWidget();
        return;
    }

    //clear list
    ui.currentActions->clear();

    QMapIterator<QString, ActionData*> ite(actionsMap);//ite, i, iterator, depending on the context and my energy
    while(ite.hasNext()){
        ite.next();
        if(ite.value()->getName().contains(str, Qt::CaseInsensitive) &&
           (actionsUsed.indexOf(ite.key()) != -1)){
            this->addItem(ite.key(), ui.currentActions);
        }
    }

}
Esempio n. 15
0
void THashTest::TestHMap1() {
    typedef yhash_map<char, Stroka, THash<char>, TEqualTo<char> > maptype;
    maptype m;
    // Store mappings between roman numerals and decimals.
    m['l'] = "50";
    m['x'] = "20"; // Deliberate mistake.
    m['v'] = "5";
    m['i'] = "1";
    UNIT_ASSERT(!strcmp(m['x'].c_str(),"20"));
    m['x'] = "10"; // Correct mistake.
    UNIT_ASSERT(!strcmp(m['x'].c_str(),"10"));

    UNIT_ASSERT(!m.has('z'));
    UNIT_ASSERT(!strcmp(m['z'].c_str(),""));
    UNIT_ASSERT(m.has('z'));

    UNIT_ASSERT(m.count('z') == 1);
    TPair<maptype::iterator, bool> p = m.insert(TPair<const char, Stroka>('c', Stroka("100")));

    UNIT_ASSERT(p.second);

    p = m.insert(TPair<const char, Stroka>('c', Stroka("100")));
    UNIT_ASSERT(!p.second);

    //Some iterators compare check, really compile time checks
    maptype::iterator ite(m.begin());
    maptype::const_iterator cite(m.begin());
    cite = m.begin();
    maptype const& cm = m;
    cite = cm.begin();

    UNIT_ASSERT((maptype::const_iterator)ite == cite);
    UNIT_ASSERT(!((maptype::const_iterator)ite != cite));
    UNIT_ASSERT(cite == (maptype::const_iterator)ite);
    UNIT_ASSERT(!(cite != (maptype::const_iterator)ite));
}
Esempio n. 16
0
BddNodeHandle BddManager::makeOr(BddNodeHandle pFst, BddNodeHandle pSnd) {
    return ite(pFst, BddNode::getConstOneHandle(), pSnd);
}
Esempio n. 17
0
CdFilenameStr& CdFilenameStr::setFullpathFilename( std::wstring ev ) 
{
	// --------------------------------
	//	すべて削除
	// --------------------------------
	m_strDrive.erase() ;
	m_contstrDir.clear() ;
	m_bIsRelativePath = true ;
	m_strBaseFilename.erase() ;
	m_strExtension.erase() ;
	// --------------------------------
	//	ドライブ名
	// --------------------------------
	{
		CStrCharSizeMb	ite( ev )  ;
		int	iBidx ;
		for ( iBidx = 0 ; iBidx < ite.ByteLength() ; iBidx = ite.BidxNextChar( iBidx ) ) {
			if ( ite.CsizeOfBidx( iBidx ) == 1 ){
				if ( ev[ iBidx ] == ':' ) {
					break ;	
					//iBidx = ドライブ名のあとの':'のインデクスです。
				}
				if (ev[ iBidx ] == '\\' || ev[ iBidx ] == '.' ){
					iBidx = ite.ByteLength() ;	
					//iBidx = ite.ByteLength()  は、
					//		ドライブ名がないことを示します。
				}
			}
		}
		if ( iBidx < ite.ByteLength()  ){
			m_strDrive = ev.substr( 0 , iBidx ) ; 
			ev = ev.substr( iBidx + 1 ) ; 
		}
	}	
	//ev = ドライブと次の':'を削除したものに
	//	なりました。

	// --------------------------------
	//	ファイル名	
	// --------------------------------
	if ( m_bIsValidFilename ){
		CStrCharSizeMb	ite( ev )  ;
		int	iBidx ;
		for ( iBidx = ite.BidxLast() ; iBidx >= 0 ; iBidx = ite.BidxNextChar( iBidx , -1 ) ){
			if ( ite.CsizeOfBidx( iBidx ) == 1 ){
				if ( ev[ iBidx ] == '\\' ){
					break ;	//	iBidx = ファイル名の直前の'\'か':'のインデクスです。
				}
			}
		}
		setFilename( ev.substr( iBidx + 1 ) ) ;
		ev = ev.substr( 0 , iBidx + 1 ) ; 
	}
	//ev = ファイル名を削除したものに
	//	なりました。

	// --------------------------------
	//	先頭と末尾の '\' を扱う
	// --------------------------------
	if ( ev.length() > 0 ){
		CStrCharSizeMb	ite( ev )  ;
		if ( ite.CsizeOfBidx( 0 ) == 1 && ev[0] == '\\' ){
			m_bIsRelativePath = false ;	
			//	ディレクトリの先頭が'\' なら、絶対パスです。
			ev = ev.substr( 1 ) ;
		}		
	}
	//ev=先頭の '\' を削除しました。

	if ( ev.length() > 0 ){
		CStrCharSizeMb	ite( ev )  ;
		if ( ite.CsizeOfBidx( ite.BidxLast() ) == 1 && ev[ite.BidxLast()] == '\\' ){
			ev = ev.substr( 0 , ite.BidxLast() ) ;
		}		
	}
	//ev=末尾の '\' を削除しました。

	// --------------------------------
	//	ディレクトリを、 '\' を境界で
	//	切り離します。
	// --------------------------------
	while( ev.length() > 0 ){
		CStrCharSizeMb	ite( ev )  ;
		int	iBidx ;
		for ( iBidx = 0 ; iBidx < ite.ByteLength() ; iBidx = ite.BidxNextChar( iBidx ) ){
			if ( ite.CsizeOfBidx( iBidx ) == 1 ){
				if ( ev[ iBidx ] == '\\' ) {
					break ;	
					//iBidx = ドライブ名のあとの'\'のインデクスです。
				}
			}
		}
		m_contstrDir.push_back( ev.substr( 0 , iBidx ) ) ; 
		ev = ev.substr( iBidx ) ; 
		ite.scan( ev ) ;
		if ( ite.ByteLength() > 0 ){
			if ( ite.CsizeOfBidx( 0 ) == 1 ){
				if ( ev[0] == '\\' ) {
					ev = ev.substr( 1 ) ;
				}
			}
		}
	}	

	return ( *this ) ;
}
Esempio n. 18
0
int main(int argc, char** argv){
	RegisteredModularityBInstance::InstancesPath = "C:\\Users\\manuel\\Documents\\Github\\clusterisator\\bipartite_instances\\";
	RegisteredModularityBInstance instance(women);
	instance.out();
	ModularityBPartition p(instance, instance.nbNodes()); 
	p.random();
	//RegisteredModularityBInstance::InstancesPath +"sol.txt">>p;
	std::cout << std::setw(4) << p.nbLabels();
	std::cout << std::setw(20) <<p.computeScore();
	std::cout << std::endl;
	//p.random();
	size_t ite(0);
	size_t k(0);
	size_t const kMax(instance.nbNodes());
	Double score;
	IntVector current(p.labels());
	optimize(p, score, current);

	Double best(score);
	IntVector solution(current);
	//std::ofstream file((RegisteredModularityBInstance::InstancesPath+"sol.txt").c_str());
	//for(auto const & e : p.input().edges()){
	//	if(solution[e._i]==solution[e._j]){
	//		size_t const i(std::min(e._i, e._j));
	//		size_t const j(std::max(e._i, e._j));
	//		file << "let x["<<i+1;
	//		file << ", "<<j+1-instance.nR();
	//		file << "] := "<<(solution[e._i]==solution[e._j]) << ";"<<std::endl;
	//	}
	//}
	//file.close();
	std::cout << std::setw(4) << k;
	std::cout << std::setw(4) << p.nbLabels();
	std::cout << std::setw(20)<< score;
	std::cout << std::endl;
	do{
		//std::cout <<"---------------"<<std::endl;
		++ite;
		++k;
		k=(k>kMax?1:k);
		if(!p.allLabelsUsed()){
			//size_t const newLabel(p.getUnUsedLabel());
			//for(size_t n(0); n<k && !p.allLabelsUsed(); ++n){
			//	size_t const node(Number::Generator()%instance.nbNodes());
			//	if(p.sizeOfLabel(p.label(node))>1)
			//		p.shift(node,newLabel);
			//}
			for(size_t n(0); n<k && !p.allLabelsUsed(); ++n){
				size_t const node(Number::Generator()%instance.nbNodes());
				if(p.sizeOfLabel(p.label(node))>1)
					p.shift(node,p.getUnUsedLabel());
			}
			//std::cout << std::setw(8) << k;
			//std::cout << std::setw(4) << p.nbLabels();
			//std::cout << std::setw(20)<< score;
			//std::cout << std::endl;
		}
		optimize(p, score, current);
		if(score>best+1e-6){
			std::cout << std::setw(4) << ite;
			std::cout << std::setw(4) << k;
			std::cout << std::setw(4) << p.nbLabels();
			std::cout << std::setw(20)<< score;
			std::cout << std::endl;
			k=0;
			best=score;
			solution=current;
		}else{
			p.setLabels(solution);
		}
	}while(ite<1000);
	//RegisteredModularityInstance::InstancesPath = "C:/Users/manuel/Documents/GitHub/clusterisator-master/modularity_instances/";
	//for(size_t i(0); i<AvailableModularityInstancesSize; ++i){
	//	AvailableModularityInstances id(static_cast<AvailableModularityInstances>(i));
	//	RegisteredModularityInstance instance(id);
	//	instance.exportAmpl(RegisteredModularityInstance::InstancesPath +instance.name+".dat");
	//}
	system("pause");
	return 0;
}
Esempio n. 19
0
			static libmaus2::aio::SynchronousGenericInput<uint64_t>::unique_ptr_type openWordPairFile(
				std::istream & CIS, uint64_t const n, uint64_t const offset
			)
			{
				libmaus2::suffixsort::GapArrayByteOverflowKeyAccessor acc(CIS);
				libmaus2::util::ConstIterator<libmaus2::suffixsort::GapArrayByteOverflowKeyAccessor,uint64_t> ita(&acc,0);
				libmaus2::util::ConstIterator<libmaus2::suffixsort::GapArrayByteOverflowKeyAccessor,uint64_t> ite(&acc,n);
			
				libmaus2::util::ConstIterator<libmaus2::suffixsort::GapArrayByteOverflowKeyAccessor,uint64_t> itc = std::lower_bound(ita,ite,offset);
				
				uint64_t const el = itc-ita;
				uint64_t const restel = n - el;
				
				CIS.clear();
				CIS.seekg( el * 2 * sizeof(uint64_t), std::ios::beg );
				
				libmaus2::aio::SynchronousGenericInput<uint64_t>::unique_ptr_type tSGI(
					new libmaus2::aio::SynchronousGenericInput<uint64_t>(CIS,1024,2*restel)
				);
				
				return UNIQUE_PTR_MOVE(tSGI);
			}