CSelectSmileDlg::CSelectSmileDlg(CWnd* pParent /*=NULL*/) : COFSNcDlg2(CSelectSmileDlg::IDD, pParent) { //{{AFX_DATA_INIT(CSelectSmileDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT SetBoundary(0,0); SetCaption(RGB(0,0,0),RGB(0,0,0),0); m_strSkinSettings = _T("/Shell/Smiles/skin.xml"); m_SelectedSmileIndex = -1; }
BMIMEMultipartMailContainer::BMIMEMultipartMailContainer( const char *boundary, const char *this_is_an_MIME_message_text, uint32 defaultCharSet) : BMailContainer (defaultCharSet), _boundary(NULL), _MIME_message_warning(this_is_an_MIME_message_text), _io_data(NULL) { // Definition of the MIME version in the mail header should be enough SetHeaderField("MIME-Version","1.0"); SetHeaderField("Content-Type","multipart/mixed"); SetBoundary(boundary); }
boss_twin_baseAI(Creature* creature, uint32 bossId) : BossAI(creature, bossId) { AuraState = AURA_STATE_NONE; Weapon = 0; SisterNpcId = 0; MyEmphatySpellId = 0; OtherEssenceSpellId = 0; SurgeSpellId = 0; VortexSpellId = 0; ShieldSpellId = 0; TwinPactSpellId = 0; SpikeSpellId = 0; TouchSpellId = 0; SetBoundary(instance->GetBossBoundary(DATA_TWIN_VALKIRIES)); }
BOOL COFSNcDlg2::OnInitDialog() { OFS_NCDLG2_PARENT::OnInitDialog(); SetBoundary(0, 0); if(m_bLoadSkin) { LoadSkin(); Invalidate(); } m_ToolTip.Create(this); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
boss_essence_of_desire(Creature* creature) : BossAI(creature, DATA_ESSENCE_OF_DESIRE), _dead(false) { SetBoundary(instance->GetBossBoundary(DATA_RELIQUARY_OF_SOULS)); }
boss_essence_of_suffering(Creature* creature) : BossAI(creature, DATA_ESSENCE_OF_SUFFERING), _dead(false) { SetBoundary(instance->GetBossBoundary(DATA_RELIQUARY_OF_SOULS)); }
Problem(Teuchos::ParameterList& list, const Teuchos::RCP<const Map>& map) : list_(list) { Map_ = map; SetBoundary(); };
Problem(Teuchos::ParameterList& list) : list_(list) { SetBoundary(); };
npc_hellfire_channelerAI(Creature* creature) : ScriptedAI(creature), _instance(me->GetInstanceScript()), _canCastDarkMending(true) { SetBoundary(_instance->GetBossBoundary(DATA_MAGTHERIDON)); }
IllidariCouncilBossAI(Creature* creature, uint32 bossId) : BossAI(creature, bossId), _bossId(bossId) { SetBoundary(instance->GetBossBoundary(DATA_ILLIDARI_COUNCIL)); }
int main(int argc, char *argv[]) { Entity et; int error, startupflags, i; char *restartname, name[128]; #ifdef PARALLEL const ParCommand end = EXIT; #endif InitVarTable(); #ifdef PARALLEL IsMaster(); if (master) { printf("MetPhoMod Rel. 2.2\n" SYSTEM " parallel Version - " DATE "\n\n"); #else printf("MetPhoMod Rel. 2.2\n" SYSTEM " sequential Version - " DATE "\n\n"); #endif if (argc > 1 && (!strcmp(argv[1], "-help") || !strcmp(argv[1], "-h"))) { McInterface::modmanager.Init1(); PrintHelp(argc - 2, argv + 2); exit (0); } if (argc > 1 && !strcmp(argv[1], "-genchem")) { if (argc != 3) goto instant_help; GenerateSpecialChem(argv[2]); exit (0); } startupflags = AnalizeOptions(&argc, argv, &restartname); if (argc != 2) { instant_help : printf("Usage : meteochem [-RESTART restart-file [-REOPEN]] [-noexcpt] [-syntax] \\\n" " [-nooutput] [-debug] [-sequential] inpfile\n" "or : meteochem (-h | -help) [keyword]\n" "or : meteochem -genchem chemfile\n"); return (1); } McInterface::modmanager.Init1(); if (startupflags & SYNTAX_ONLY) { if (ParseInput(argv[1])) { printf("Errors in Input-File\n"); return (1); } else { printf("the input-file seems to be OK!\n"); return (0); } } #ifdef PARALLEL if (startupflags & SEQUENTIAL) { parallel = FALSE; master = TRUE; leftest = rightest = TRUE; } } if (master) { #endif if (ParseInput(argv[1])) { fprintf(stderr, "Errors parsing Input-File. I don't start the calculation.\n"); return (1); } plausible = TRUE; if (!(startupflags & NOEXCPT)) InstallFpeHandler(); tinc = chemtinc = tincmax; actime = chemtime = tstart; #ifdef PARALLEL if (!parallel) printf("\n\n!!! Using sequential mode !!!\n\n"); else McInterface::modmanager.CheckIfReadyForParallel(); } InitializeWorkers(argv[0], startupflags & DEBUG_WORKERS); if (parallel && !master) { if (!(startupflags & NOEXCPT)) InstallFpeHandler(); McInterface::modmanager.Init1(); ReadDataFromMaster(); InitializeData(); plausible = TRUE; tinc = chemtinc = tincmax; actime = chemtime = tstart; } if (parallel && master) { printf("Sending Data to workers...\n"); SendDataToWorkers(); InitializeData(); } if (!parallel) #endif InitializeData(); for (et = maxentity; et--; ) if (g[et]) CalculateLayerAverage(g[et], pstat, avg+et*nz); else memset(avg+et*nz, 0, nz*sizeof(double)); CalcMeanHydrostaticPressure(); #ifdef PARALLEL if (!parallel || !master) { #endif SetAvgMountains(); SetBoundary(maxentity); /* CalcAllKm(); */ #ifdef PARALLEL } if (parallel && !master) { if (GetRestartName(name)) { if (!(ReadFullDump(name, (startupflags & REOPEN)) && actime <= tend)) { printf("Error : Restart-file not found\n"); plausible = FALSE; } } } else { if (parallel) SendRestartName((startupflags & RESTART) ? restartname : NULL); #endif if (startupflags & RESTART) { if (!ReadFullDump(restartname, (startupflags & REOPEN))) { printf("Error : Restart-file not found\n"); return (1); } } else if (startupflags & REOPEN) { printf("Error: -REOPEN can only be used together with -RESTART\n"); return (1); } #ifdef PARALLEL } if (master) { #endif if (!(startupflags & NO_OUTPUT)) { printf("Opening output-Files..."); if (OpenOutputFiles(argv[1], (startupflags & RESTART) && (startupflags & REOPEN))) { printf("\nExecution abortet\n"); exit (1); } CreateDomainFiles((startupflags & RESTART) && (startupflags & REOPEN)); } InstallSignalHandler(); printf("\n"); #ifdef PARALLEL if (parallel) printf("Starting calculation...\n"); } #else printf("Starting calculation...\n"); #endif #if PARALLEL if (!parallel || master) #endif if (!(startupflags & NO_OUTPUT)) { WriteOutData(tstart, FALSE); WriteToDomainFiles(tstart); } /* TestChemicals("Start"); */ #if PARALLEL if (parallel) if (master) MastersLoop(startupflags); else WorkersLoop(startupflags); else #endif SequentialLoop(startupflags); printf("Closing output-Files...\n"); if (plausible) printf("Calculation terminated successfully\n\n"); else { if (!(startupflags & NO_OUTPUT)) WriteOutData(actime, TRUE); printf("Calculation stopped because of inplausibilities!\n\n"); } if (!(startupflags & NO_OUTPUT)) { CloseOutputFiles(); CloseDomainFiles(); } #ifdef PARALLEL if (parallel) { pvm_initsend(PvmDataRaw); pvm_pkint((int *)&end, 1, 1); SendCommand(); pvm_exit(); } #endif return (0); }
void WorkersLoop(int startupflags) { double theta; long daytime, newtinc; Entity et; Vector sunpos; VarDesc *v; int i, j, k; char varname[80]; while (1) { switch (GetCommand()) { case DO_TIME_STEP : if (plausible) { daytime = ((int)(timeofday*3600.)+actime) % 86400; ActualiseValuesInTime(actime); /* Actualise Border values */ for (et = maxentity; et--; ) CalculateLayerAverage(g[et], pstat, avg+et*nz); SetAvgMountains(); CalcMeanHydrostaticPressure(); InterpolateToFaces(); /* Interpolate wind speeds from center to faces */ InterpolateToCenter(-1., pressuretype == NONHYDROSTATIC); if (tstart == actime) Continuity(); CheckTimeStep(&tinc, &chemtinc, 0.8); if (pressuretype == NONHYDROSTATIC) ApplyBuoyancy(tinc); /* Calculate Buoyancy */ if (pressuretype != NOPRESSURE) { /* Calc wind acceleration */ switch (pressuretype) { /* Calculate Pressure field */ case HYDROSTATIC : CalcHydrostaticPressure(); break; case NONHYDROSTATIC : SolveForPressure(tinc); break; } ApplyPressure(tinc); } Continuity(); /* Mass conservation */ InterpolateToCenter(1., pressuretype == NONHYDROSTATIC); if (coriolistype != NOCORIOLIS) ApplyCoriolis(tinc); if (filtertype != NO_FILTER) { SetBoundary(WWIND+1); /* Set Boundary for Wind only */ switch (filtertype) { case PEPPER_FILTER : for (i = nz; i--; ) for (et = HUMIDITY; et--; ) ApplyFilter(g[et]+i*layer, pstat+i*layer, spatialfilter); break; case SHAPIRO_FILTER : for (i = nz; i--; ) for (et = HUMIDITY; et--; ) ShapiroFilter(g[et]+i*layer, pstat+i*layer, 3, spatialfilter); break; case DIFFUSION_FILTER : for (i = nz; i--; ) for (et = HUMIDITY; et--; ) ShapiroFilter(g[et]+i*layer, pstat+i*layer, 1, spatialfilter); break; } } SetBoundary(WWIND+1); CheckTimeStep(&newtinc, &chemtinc, 1.); if (newtinc < tinc) { tinc = newtinc; } chemtinc = (chemtime <= actime ? chemtinc : 0); if (advection || windadvection) switch (advectiontype) { case MPDATA_A : Advect(tinc, chemtinc); break; case PPM_A : PPM_Transport(tinc, chemtinc, smiord); break; } if (dampinglayer) DampTop(); if (groundinterface || shortwaveradiation) { GroundInterface(timeofday + (double)actime / 3600., dayofyear, tinc, &sunpos); sunelevation = (sunpos.z > 0. ? 57.29578 * asin(sunpos.z) : 0.); } if (cloudwater) CloudPhysics(); if (turbtype == TTTT) { if (groundinterface) CalcGroundTurbulence(tinc); CalcTransilientTurbulence(tinc); } else if (turbtype == KEPS_T) { CalcKEpsilon(tinc); if (groundinterface) CalcGroundTurbulence(tinc); CalcKTurb(tinc, chemtinc); } Emit(tinc); Deposit(tinc); if (!(radiationtype && shortwaveradiation) && // When using the two-stream module, ChemicalTimeStep // mus be called from within ShortWaveRadiation! nsubs && actime % tchem == 0) ChemicalTimeStep(tchem, &sunpos); SetBoundary(chemtinc ? maxentity : SUBS); // Call ModuleManager McInterface::modmanager.DoCalc(actime+tinc); actime += tinc; chemtime += chemtinc; if (dumpnow || (dumptime && (actime % dumptime == 0))) { MakeAFullDump(); dumpnow = 0; } } /* if (plausible) */ SendStatus(plausible); break; case SENDGRIDVAL : pvm_upkint((int *)&et, 1, 1); pvm_upkint(&i, 1, 1); pvm_upkint(&j, 1, 1); pvm_upkint(&k, 1, 1); pvm_initsend(PvmDataRaw); pvm_pkdouble(g[et]+i*row+j+k*layer, 1, 1); pvm_send(myparent, VALUES); break; case SENDMESHVAL : pvm_upkstr(varname); v = GetNamedVar(varname); pvm_upkint(&i, 1, 1); pvm_upkint(&j, 1, 1); pvm_upkint(&k, 1, 1); pvm_initsend(PvmDataRaw); if (v->storetype == PROC_VAL) { theta = v->v.proc(k, i, j, v); pvm_pkdouble(&theta, 1, 1); } else pvm_pkdouble(GetNamedVar(varname)->v.d+i*row+j+k*layer, 1, 1); pvm_send(myparent, VALUES); break; case SENDGRID : pvm_upkint((int *)&et, 1, 1); SendMeshToMaster(g[et], 0, ALL_DIM); break; case SENDMESH : pvm_upkstr(varname); v = GetNamedVar(varname); if (v->storetype == PROC_VAL) { for (k = nz; k--; ) for (i = nx+1; i--; ) for (j = ny+1; j--; ) flux[0][i*row+j+k*layer] = v->v.proc(k, i, j, v); SendMeshToMaster(flux[0], 0, v->dims); memset(flux[0], 0, mesh * sizeof(double)); } else SendMeshToMaster(v->v.d, 0, v->dims); break; case SENDGROUND : SendGroundToMaster(); break; case EXIT : pvm_exit(); exit (0); } } }
void SequentialLoop(int startupflags) { int i; double theta; long daytime, newtinc; Entity et; Vector sunpos; while (plausible && actime < tend) { daytime = ((int)(timeofday*3600.)+actime) % 86400; printf("Now at %li seconds = %02li:%02li:%02li ", actime, daytime / 3600, (daytime % 3600)/60, daytime % 60); ActualiseValuesInTime(actime); /* Actualise Border values */ for (et = maxentity; et--; ) CalculateLayerAverage(g[et], pstat, avg+et*nz); SetAvgMountains(); CalcMeanHydrostaticPressure(); InterpolateToFaces(); /* Interpolate wind speeds from center to faces */ InterpolateToCenter(-1., pressuretype == NONHYDROSTATIC); if (tstart == actime) Continuity(); CheckTimeStep(&tinc, &chemtinc, 0.8); if (pressuretype == NONHYDROSTATIC) ApplyBuoyancy(tinc); /* Calculate Buoyancy */ if (pressuretype != NOPRESSURE) { /* Calc wind acceleration */ switch (pressuretype) { /* Calculate Pressure field */ case HYDROSTATIC : CalcHydrostaticPressure(); break; case NONHYDROSTATIC : SolveForPressure(tinc); break; } ApplyPressure(tinc); } Continuity(); /* Mass conservation */ InterpolateToCenter(1., pressuretype == NONHYDROSTATIC); if (coriolistype != NOCORIOLIS) ApplyCoriolis(tinc); if (filtertype != NO_FILTER) { SetBoundary(WWIND+1); switch (filtertype) { case PEPPER_FILTER : for (i = nz; i--; ) for (et = HUMIDITY; et--; ) ApplyFilter(g[et]+i*layer, pstat+i*layer, spatialfilter); break; case SHAPIRO_FILTER : for (i = nz; i--; ) { for (et = HUMIDITY; et--; ) ShapiroFilter(g[et]+i*layer, pstat+i*layer, 3, spatialfilter); /* if (turbtype == KEPS_T) { ShapiroFilter(g[TKE]+i*layer, pstat+i*layer, 3, spatialfilter); ShapiroFilter(g[EPS]+i*layer, pstat+i*layer, 3, spatialfilter); } */ } break; case DIFFUSION_FILTER : for (i = nz; i--; ) for (et = HUMIDITY; et--; ) ShapiroFilter(g[et]+i*layer, pstat+i*layer, 1, spatialfilter); break; } } SetBoundary(WWIND+1); CheckTimeStep(&newtinc, &chemtinc, 1.); if (newtinc < tinc) { fprintf(stderr, "Warning: Time step had to be changed in the middle of iteration\n"); tinc = newtinc; } chemtinc = (chemtime <= actime ? chemtinc : 0); if (nsubs) printf("chemtinc = %3ld ", chemtinc); if (advection || windadvection) switch (advectiontype) { case MPDATA_A : Advect(tinc, chemtinc); break; case PPM_A : PPM_Transport(tinc, chemtinc, smiord); break; } if (dampinglayer) DampTop(); if (groundinterface || shortwaveradiation) { GroundInterface(timeofday + (double)actime / 3600., dayofyear, tinc, &sunpos); sunelevation = (sunpos.z > 0. ? 57.29578 * asin(sunpos.z) : 0.); } if (cloudwater) CloudPhysics(); if (turbtype == TTTT) { if (groundinterface) CalcGroundTurbulence(tinc); CalcTransilientTurbulence(tinc); } else if (turbtype == KEPS_T) { CalcKEpsilon(tinc); if (groundinterface) CalcGroundTurbulence(tinc); CalcKTurb(tinc, chemtinc); } Emit(tinc); Deposit(tinc); if (!(radiationtype && shortwaveradiation) && // When using the two-stream module, ChemicalTimeStep // must be called from within ShortWaveRadiation! nsubs && actime % tchem == 0) ChemicalTimeStep(tchem, &sunpos); SetBoundary(chemtinc ? maxentity : SUBS); // Call ModuleManager McInterface::modmanager.DoCalc(actime+tinc); /* TestChemicals("Boundary"); */ actime += tinc; chemtime += chemtinc; if (!(startupflags & NO_OUTPUT)) { WriteOutData(actime, FALSE); WriteToDomainFiles(actime); } if (dumpnow || (dumptime && (actime % dumptime == 0))) { MakeAFullDump(); dumpnow = 0; } if (mailtime) { mailtime = 0; MailTheTime(); } printf("Energy = %lf\n", CalcTopEnergy()); } }
void Flow2D::AddVelocityOnLine(int fromPx, int fromPy, int toPx, int toPy,float vel, const int bold) { if (vel<= 0.0) return; int iVx = toPx - fromPx; int iVy = toPy - fromPy; vel = vel/sqrtf((float)(iVx * iVx + iVy * iVy)); if ( vel == 0.0f ) return; float mx, my; int px,py; float fVx = float(iVx) * vel; float fVy = float(iVy) * vel; if (fVx == 0.0f) { if (fromPy > toPy) { Swap(fromPx, toPx); Swap(fromPy, toPy); } for (int j = fromPy; j <= toPy; j++) { for (int i = fromPx - bold; i <= fromPx + bold; i++){ AddVelocity(GetIndex(i, j), fVx, fVy); } } } else if (fVy == 0.0f) { if (fromPx > toPx) { Swap(fromPx, toPx); Swap(fromPy, toPy); } for (int i = fromPx; i < toPx; i++) { for (int j = fromPy - bold; j <= fromPy + bold; j++) { AddVelocity(GetIndex(i, j), fVx, fVy); } } } else { mx = (float)(fVy / fVx); if (fabs(mx) < 1.0) { if (fromPx > toPx) { Swap(fromPx, toPx); Swap(fromPy, toPy); } for (int i = fromPx; i < toPy; i++) { py = (int)( mx * (i - fromPx) + fromPy); for (int j = py - bold; j <= py + bold; j++) { AddVelocity(GetIndex(i, j),fVx, fVy); } } } else { if (fromPy > toPy) { Swap(fromPx, toPx); Swap(fromPy, toPy); } my = (float)(fVx / fVy); for (int j = fromPy; j < toPy; j++) { px = (int)(my * (j - fromPy) + fromPx); for(int i = px - bold ; i <= px + bold; i++){ AddVelocity(GetIndex(i, j), fVx, fVy); } } } } SetBoundary(m_Vel.x.aligned); SetBoundary(m_Vel.y.aligned); }
void Flow2D::SolvePoissonEq() { // bool loopEnd; const float h2 = 2.0; const float h4 = 4.0; int iX, iY; // float* tmpA; // float* velX; // float* velY; for (int i = 0; i < m_Nsite; i++) { iX = i%m_Nsite; iY = i/m_Nsite; m_TmpA.aligned[i] = (m_Vel.x.aligned[GetIndexFull(iX+1,iY)] - m_Vel.x.aligned[GetIndexFull(iX-1, iY)] + m_Vel.y.aligned[GetIndexFull(iX,iY+1)] - m_Vel.y.aligned[GetIndexFull(iX, iY-1)]) / h2; /* tmpA = m_TmpA.aligned+i; velX = m_Vel.x.aligned; velY = m_Vel.y.aligned; __asm { push eax mov eax, mov eax, tmpA } */ } for (int j = 0; j< m_iteration; j++) { Swap(m_Vel.aux.aligned, m_Vel.vor.aligned); // loopEnd = true; for (int i = 0; i < m_Nsite; i++) { iX = i%m_Nsite; iY = i/m_Nsite; m_Vel.aux.aligned[GetIndexFull(iX, iY)] = (m_Vel.vor.aligned[GetIndexFull(iX+1,iY)] + m_Vel.vor.aligned[GetIndexFull(iX-1,iY)] + m_Vel.vor.aligned[GetIndexFull(iX, iY+1)] + m_Vel.vor.aligned[GetIndexFull(iX, iY-1)] - m_TmpA.aligned[i]) / h4; // if ( loopEnd && (m_Aux[j] - m_TmpB[j]) > residual * m_Aux[j] ) { // loopEnd = false; // } } SetBoundary(m_Vel.aux.aligned); // if (loopEnd) { // break; // } } for (int i = 0; i < m_Nsite; i++) { iX = i%m_Nsite; iY = i/m_Nsite; m_Vel.x.aligned[GetIndexFull(iX, iY)] -= (m_Vel.aux.aligned[GetIndexFull(iX+1, iY)] - m_Vel.aux.aligned[GetIndexFull(iX-1, iY)]) / h2; m_Vel.y.aligned[GetIndexFull(iX, iY)] -= (m_Vel.aux.aligned[GetIndexFull(iX, iY +1)] - m_Vel.aux.aligned[GetIndexFull(iX, iY-1)]) / h2; } SetBoundary(m_Vel.x.aligned); SetBoundary(m_Vel.y.aligned); }
boss_essence_of_anger(Creature* creature) :BossAI(creature, DATA_ESSENCE_OF_ANGER) { SetBoundary(instance->GetBossBoundary(DATA_RELIQUARY_OF_SOULS)); }
boss_northrend_beastsAI(Creature* creature, uint32 bossId) : BossAI(creature, bossId) { SetBoundary(instance->GetBossBoundary(DATA_NORTHREND_BEASTS)); }
void ADMMCut::MakeLayers() { // Initial Cutting Edge Setting InitState(); debug_ = false; int cut_count = 0; vector<double> cut_energy; vector<double> res_energy; do { /* Recreate dual graph at the beginning of each cut */ SetStartingPoints(cut_count); CreateA(); ptr_stiff_->CalculateD(D_, x_, 0, 0, cut_count); ///* for rendering */ //if (cut_count == 0) //{ // WriteWeight(); // WriteStiffness("offset1.txt", "rotation1.txt"); // getchar(); //} //if (cut_count == 4) //{ // WriteStiffness("offset2.txt", "rotation2.txt"); // getchar(); //} //if (cut_count == 6) //{ // WriteStiffness("offset3.txt", "rotation3.txt"); // getchar(); //} /* set x for intial cut setting */ SetBoundary(); /* * energy specify: * cut energy : | A * x | * defomation energy : norm(K D - F) */ ptr_stiff_->CreateGlobalK(x_); ptr_stiff_->CreateF(x_); SpMat K_init = *(ptr_stiff_->WeightedK()); VX F_init = *(ptr_stiff_->WeightedF()); double icut_energy = 0; VX V_Cut = A_ * x_; for (int i = 0; i < Md_; i++) { icut_energy += abs(V_Cut[i]); } double ideform_energy = (K_init * D_ - F_init).norm(); cout << "****************************************" << endl; cout << "ADMMCut Round : " << cut_count << endl; cout << "Initial cut energy before entering ADMM: " << icut_energy << endl; cout << "Initial Lagrangian energy before entering ADMM: " << ideform_energy << endl; cout << "---------------------------------" << endl; int rew_count = 0; VX x_prev; VX D_prev; /* Output energy list for reweighting process in a single graph cut problem, energy.size() = number of reweighting process performed. cut energy = |A_ * x_| = sum_{e_ij} w_ij * |x_i - x_j| res energy = (K(x)D - F(x)).norm() */ cut_energy.clear(); res_energy.clear(); cut_energy.push_back(icut_energy); res_energy.push_back(ideform_energy); do { /* Reweighting loop for cut */ int ADMM_count = 0; x_prev = x_; CreateC(cut_count, rew_count); do { cout << "ADMMCut Round: " << cut_count << ", reweight iteration:" << rew_count << ", ADMM " << ADMM_count << " iteration." << endl; /*-------------------ADMM loop-------------------*/ CalculateX(); D_prev = D_; CalculateD(); UpdateLambda(); /*-------------------Residual Calculation-------------------*/ SpMat Q_prev; SpMat Q_new; CalculateQ(D_prev, Q_prev); CalculateQ(D_, Q_new); /* Update K reweighted by new x */ ptr_stiff_->CreateGlobalK(x_); ptr_stiff_->CreateF(x_); SpMat K_new = *(ptr_stiff_->WeightedK()); VX F_new = *(ptr_stiff_->WeightedF()); dual_res_ = penalty_ * (D_prev - D_).transpose() * K_new.transpose() * Q_prev + lambda_.transpose() * (Q_prev - Q_new); primal_res_ = K_new * D_ - F_new; /*-------------------Screenplay-------------------*/ double new_cut_energy = x_.dot(H1_ * x_); cout << "new quadratic func value record: " << new_cut_energy << endl; cout << "dual_residual : " << dual_res_.norm() << endl; cout << "primal_residual(KD-F) : " << primal_res_.norm() << endl; cout << "---------------------" << endl; ADMM_count++; } while (!TerminationCriteria(ADMM_count)); /* One reweighting process ended! */ /* Output energy and residual */ double energy = 0; VX V_Cut = A_ * x_; for (int i = 0; i < Md_; i++) { energy += ptr_dualgraph_->Weight(i) * abs(V_Cut[i]); } /*-------------------Screenplay-------------------*/ double res_tmp = primal_res_.norm(); cout << "Cut " << cut_count << " Reweight " << rew_count << " completed." << endl; cout << "Cut Energy :" << energy << endl; cout << "Res Energy :" << res_tmp << endl; cout << "<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-" << endl; cut_energy.push_back(energy); res_energy.push_back(res_tmp); /* write x distribution to a file */ string str_x = "Cut_" + to_string(cut_count) + "_Rew_" + to_string(rew_count) + "_x"; Statistics tmp_x(str_x, x_); tmp_x.GenerateVectorFile(); rew_count++; } while (!UpdateR(x_prev, rew_count)); /* Output reweighting energy history for last cut process */ string str_eC = "Cut_" + to_string(cut_count) + "_Cut_Energy"; Statistics s_eC(str_eC, cut_energy); s_eC.GenerateStdVecFile(); string str_eR = "Cut_" + to_string(cut_count) + "_Res_Energy"; Statistics s_eR(str_eR, res_energy); s_eR.GenerateStdVecFile(); /* Update New Cut information to Rendering (layer_label_) */ UpdateCut(); fprintf(stdout, "ADMMCut No.%d process is Finished!\n", cut_count); cut_count++; } while (!CheckLabel(cut_count)); fprintf(stdout, "All done!\n"); }