void vpSystem::IDIteration2(void) { int i, j; vpJoint *pCurrent, *pChild; for ( i = m_pJoint.size() - 1; i >= 0; i-- ) { pCurrent = m_pJoint[i]; pCurrent->m_sF = pCurrent->m_sI * pCurrent->m_sDV - dad(pCurrent->m_sV, pCurrent->m_sI * pCurrent->m_sV); for ( j = 0; j < pCurrent->m_pChildJoints.size(); j++ ) { pChild = pCurrent->m_pChildJoints[j]; pCurrent->m_sF += InvdAd(pChild->m_sRelativeFrame, pChild->m_sF); } pCurrent->m_sF -= dAd(pCurrent->m_sRightBodyFrame, pCurrent->m_pRightBody->GetForce()); pCurrent->UpdateTorqueID(); } if ( m_pRoot->m_bIsGround ) return; m_pRoot->m_sForce = m_pRoot->m_sI * m_pRoot->m_sDV - dad(m_pRoot->m_sV, m_pRoot->m_sI * m_pRoot->m_sV); for ( i = 0; i < m_pRoot->m_pJoint.size(); i++ ) { pChild = m_pRoot->m_pJoint[i]; m_pRoot->m_sForce += InvdAd(pChild->m_sRelativeFrame, pChild->m_sF); } m_pRoot->m_sForce -= m_pRoot->GetGravityForce(); }
void vpSystem::HDIteration2(void) { int i, j; vpJoint *pCurrent, *pChild; AInertia tmpI; for ( i = m_pJoint.size() - 1; i >= 0; i-- ) { pCurrent = m_pJoint[i]; pCurrent->m_sJ = pCurrent->m_sI; pCurrent->m_sB = -dad(pCurrent->m_sV, pCurrent->m_sI * pCurrent->m_sV) - dAd(pCurrent->m_sRightBodyFrame, pCurrent->m_pRightBody->GetForce()); for ( j = 0; j < pCurrent->m_pChildJoints.size(); j++ ) { pChild = pCurrent->m_pChildJoints[j]; if ( pChild->m_sHDType == VP::KINEMATIC ) { pCurrent->m_sJ.AddTransform(pChild->m_sJ, Inv(pChild->m_sRelativeFrame)); } else { pChild->UpdateAInertia(tmpI); pCurrent->m_sJ.AddTransform(tmpI, Inv(pChild->m_sRelativeFrame)); } pCurrent->m_sB += InvdAd(pChild->m_sRelativeFrame, pChild->m_sC + pChild->GetLP()); } pCurrent->m_sC = pCurrent->m_sB + pCurrent->m_sJ * pCurrent->m_sW; if ( pCurrent->m_sHDType == VP::KINEMATIC ) pCurrent->UpdateLP(); else pCurrent->UpdateLOTP(); } if ( m_pRoot->m_bIsGround ) return; if ( m_pRoot->m_pJoint.size() ) m_sRootInertia = m_pRoot->m_sI; m_sRootBias = -dad(m_pRoot->m_sV, m_pRoot->m_sI * m_pRoot->m_sV); if ( m_pRoot->m_sHDType == VP::DYNAMIC ) m_sRootBias -= m_pRoot->GetForce(); else m_sRootBias -= m_pRoot->GetGravityForce(); for ( i = 0; i < m_pRoot->m_pJoint.size(); i++ ) { pChild = m_pRoot->m_pJoint[i]; if ( pChild->m_sHDType == VP::KINEMATIC ) { m_sRootInertia.AddTransform(pChild->m_sJ, Inv(pChild->m_sRelativeFrame)); } else { pChild->UpdateAInertia(tmpI); m_sRootInertia.AddTransform(tmpI, Inv(pChild->m_sRelativeFrame)); } m_sRootBias += InvdAd(pChild->m_sRelativeFrame, pChild->m_sC + pChild->GetLP()); } }
// Complexidade Log(n) void up_it(eHeap *e, int i){ int k; if(i< e->size){ k = dad(i); while(i != k){ if(e->elements[k].el < e->elements[i].el){ exchange(e,k,i); i = k; k = dad(i); } } } return; }
int main() { int n,cases=0; scanf("%d",&n); while(cases++<n) { count=0; memset(visit,0,sizeof(visit)); memset(a,0,sizeof(a)); dlx_init(81*4); int k=0,i=0,j=0,s=1; for(i=0;i<9;i++) for(j=0;j<9;j++) { scanf("%d",&map[i][j]); a[i][j]=map[i][j]&(~15); map[i][j]=map[i][j]&15; } for(i=0;i<9;i++) for(j=0;j<9;j++) if(!visit[i][j]) dfs(i,j,s++); for(i=0;i<9;i++) for(j=0;j<9;j++) if(map[i][j]==0) { int ii; for(ii=1;ii<=9;ii++) dad(i,j,ii); } else dad(i,j,map[i][j]); DLX(0); printf("Case %d:\n",cases); if(!count) printf("No solution\n"); else if(count==1) for(i=0;i<9;i++) { for(j=0;j<9;j++) printf("%d",map[i][j]); printf("\n"); } else printf("Multiple Solutions\n"); } return 0; }
void DeepAd(Dataset * combinDataSet, int nLayers, int layerSizes[],double lr, int batchsize, int epochs, string savefile){ printf("lr: %f\nlayers: %d\nlayersize: %d\t%d\t%d\nbatchsize :%d\nepochs :%d\nsavefile: %s\n", lr, nLayers, layerSizes[0],layerSizes[1], layerSizes[2], batchsize, epochs, savefile.c_str()); DeepAutoEncoder dad(2,layerSizes); dad.setModelFile("result/com_dad.dat"); TrainModel model(&dad); model.train(combinDataSet,lr,batchsize,epochs); TransmissionDataset out(combinDataSet,&dad); out.dumpTrainData(savefile.c_str()); }
void up(eHeap *e, int i){ int k; if(i< (e->size)){ // se o indice for valido. k = dad(i); if(i == k) return; if(e->elements[k].el < e->elements[i].el){ exchange(e,k,i); } up(e,k); } return; }
void GSystem::calcDerivative_MomentumCOM_Dq_Ddq(RMatrix &DHcDq_, RMatrix &DHcDdq_) { int i; std::list<GBody *>::iterator iter_pbody; std::list<GCoordinate *>::iterator iter_pcoord; std::vector<SE3> M(pBodies.size()); std::vector<GConstraintJointLoop::JOINTLOOP_CONSTRAINT_TYPE> jlc_type(pBodies.size()); for (i=0, iter_pbody = pBodies.begin(); iter_pbody != pBodies.end(); i++, iter_pbody++) { // save previous settings M[i] = (*iter_pbody)->fwdJointChain.M1; jlc_type[i] = (*iter_pbody)->fwdJointChain.jointLoopConstraintType; // prerequisites for (*iter_pbody)->getDerivative_MomentumGlobal_Dq(...) and (*iter_pbody)->getDerivative_MomentumGlobal_Ddq(...) (*iter_pbody)->fwdJointChain.setM(SE3()); (*iter_pbody)->fwdJointChain.jointLoopConstraintType = GConstraintJointLoop::JOINTLOOP_ORIENTATION_POSITION; (*iter_pbody)->fwdJointChain.update_J(); } // calculate the derivatives Vec3 p = getPositionCOMGlobal(); dse3 Hg = getMomentumGlobal(); RMatrix DHgDq(6, getNumCoordinates()), DHgDdq(6, getNumCoordinates()); dse3 DHgDqi, DHgDdqi; for (i=0, iter_pcoord = pCoordinates.begin(); iter_pcoord != pCoordinates.end(); i++, iter_pcoord++) { DHgDqi = getDerivative_MomentumGlobal_Dq(*iter_pcoord); DHgDdqi = getDerivative_MomentumGlobal_Ddq(*iter_pcoord); //DHgDq.Push(0, i, convert_to_RMatrix(DHgDqi)); //DHgDdq.Push(0, i, convert_to_RMatrix(DHgDdqi)); matSet(&DHgDq[6*i], DHgDqi.GetArray(), 6); matSet(&DHgDdq[6*i], DHgDdqi.GetArray(), 6); } RMatrix DdAdDq_Hg(6, getNumCoordinates()); Vec3 DpDqi; for (i=0, iter_pcoord = pCoordinates.begin(); iter_pcoord != pCoordinates.end(); i++, iter_pcoord++) { DpDqi = getDerivative_PositionCOMGlobal_Dq(*iter_pcoord); //DdAdDq_Hg.Push(0, i, convert_to_RMatrix(dAd(SE3(p), dad(se3(Vec3(0,0,0),DpDqi), Hg)))); matSet(&DdAdDq_Hg[6*i], dAd(SE3(p), dad(se3(Vec3(0,0,0),DpDqi), Hg)).GetArray(), 6); } DHcDq_ = dAd(SE3(p), DHgDq) + DdAdDq_Hg; DHcDdq_ = dAd(SE3(p), DHgDdq); // restore the previous settings for (i=0, iter_pbody = pBodies.begin(); iter_pbody != pBodies.end(); i++, iter_pbody++) { (*iter_pbody)->fwdJointChain.setM(M[i]); (*iter_pbody)->fwdJointChain.setJointLoopConstraintType(jlc_type[i]); } }
TEST(UX, Crossover){ Individual mom("02134"); Individual dad("41302"); std::vector<int> indices; indices.push_back(1); indices.push_back(3); UX ux(2); Individual child = ux.cross(indices, &dad, &mom); ASSERT_EQ(Individual("31204"), child); ASSERT_EQ(&dad, child.parent(0)); ASSERT_EQ(&mom, child.parent(1)); }
int my_exec(t_sh *sh, char *path) { pid_t pid; if (sh->actual->parent != NULL && (sh->actual->parent->fd[0] < 0 || sh->actual->parent->fd[1] < 0)) return (0); pid = fork(); if (pid == 0) son(sh, path); else if (pid > 0) dad(sh, pid); else my_printf("%s: Fork failed\n", sh->av[0]); return (0); }
/************************************************************************ Função para subir o elemento de indice i até sua posição correta com relação aos seus ascendentes *************************************************************************/ void up (MyHeap* heap, int i) { int k; if (i<(heap->numberOfElements)) { k = dad(i); if (i==k) return; // chegou na raiz if ((heap->S[i]).priority > (heap->S[k]).priority) { exchange (heap,i,k); up (heap,k); } } return; }