Changeset 35aef3 in git
- Timestamp:
- Jun 17, 2015, 2:30:30 PM (8 years ago)
- Branches:
- (u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
- Children:
- 500e4b69e2df574c6ae8023f32cbdfbdbd0d5e8e
- Parents:
- 3e1c75620dfadd12d3798a1aee9d665e5388539d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/walk.cc
r3e1c75 r35aef3 4361 4361 target_weight != NULL && G->m[0] != NULL); 4362 4362 4363 intvec* next_weight1 = MkInterRedNextWeight(curr_weight,target_weight,G); 4364 if(weight_rad == 0) 4365 { 4366 return(next_weight1); 4367 } 4368 4363 4369 int i,weight_norm,nV = currRing->N; 4364 intvec* next_weight2 ;4370 intvec* next_weight2 = new intvec(nV); 4365 4371 intvec* next_weight22 = new intvec(nV); 4366 4372 intvec* result = new intvec(nV); 4367 4373 4368 intvec* next_weight1 =MkInterRedNextWeight(curr_weight,target_weight,G); 4374 ideal G_test, G_test2; 4375 4369 4376 //compute a random next weight vector "next_weight2" 4370 4377 while(1) … … 4376 4383 for(i=0; i<nV; i++) 4377 4384 { 4378 (*next_weight2 2)[i] = rand() % 60000 - 30000;4379 weight_norm = weight_norm + (*next_weight2 2)[i]*(*next_weight22)[i];4385 (*next_weight2)[i] = rand() % 60000 - 30000; 4386 weight_norm = weight_norm + (*next_weight2)[i]*(*next_weight2)[i]; 4380 4387 } 4381 4388 weight_norm = 1 + floor(sqrt(weight_norm)); … … 4384 4391 for(i=0; i<nV; i++) 4385 4392 { 4386 if((*next_weight2 2)[i] < 0)4387 { 4388 (*next_weight2 2)[i] = 1 + (*curr_weight)[i] + floor(weight_rad*(*next_weight22)[i]/weight_norm);4393 if((*next_weight2)[i] < 0) 4394 { 4395 (*next_weight2)[i] = 1 + (*curr_weight)[i] + floor(weight_rad*(*next_weight2)[i]/weight_norm); 4389 4396 } 4390 4397 else 4391 4398 { 4392 (*next_weight22)[i] = (*curr_weight)[i] + floor(weight_rad*(*next_weight22)[i]/weight_norm); 4393 } 4394 } 4395 4396 if(test_w_in_ConeCC(G, next_weight22) == 1) 4397 { 4398 next_weight2 = MkInterRedNextWeight(next_weight22,target_weight,G); 4399 (*next_weight2)[i] = (*curr_weight)[i] + floor(weight_rad*(*next_weight2)[i]/weight_norm); 4400 } 4401 } 4402 4403 if(test_w_in_ConeCC(G, next_weight2) == 1) 4404 { 4405 PrintS("\n Hier 1\n"); 4406 G_test2 = MwalkInitialForm(G, next_weight2); 4407 PrintS("\n Hier 2\n"); 4408 if(maxlengthpoly(G_test2) <= 1) 4409 { 4410 next_weight2 = MkInterRedNextWeight(next_weight2,target_weight,G); 4411 } 4412 idDelete(&G_test2); 4413 4399 4414 if(MivAbsMax(next_weight2)>1147483647) 4400 4415 { … … 4404 4419 } 4405 4420 i = 0; 4406 / * reduce the size of the maximal entry of the vector*/4407 while(test_w_in_ConeCC(G,next_weight22) )4421 // reduce the size of the maximal entry of the vector 4422 while(test_w_in_ConeCC(G,next_weight22) == 1) 4408 4423 { 4409 4424 (*next_weight2)[i] = (*next_weight22)[i]; … … 4411 4426 (*next_weight22)[i] = floor(0.1*(*next_weight22)[i] + 0.5); 4412 4427 } 4413 }4414 delete next_weight22;4428 delete next_weight22; 4429 } 4415 4430 break; 4416 4431 } 4432 weight_rad++; 4417 4433 } 4418 4434 4419 4435 // compute "usual" next weight vector 4420 4436 intvec* next_weight = MwalkNextWeightCC(curr_weight,target_weight, G); 4421 idealG_test = MwalkInitialForm(G, next_weight);4422 idealG_test2 = MwalkInitialForm(G, next_weight2);4437 G_test = MwalkInitialForm(G, next_weight); 4438 G_test2 = MwalkInitialForm(G, next_weight2); 4423 4439 4424 4440 // compare next weights … … 4426 4442 { 4427 4443 ideal G_test1 = MwalkInitialForm(G, next_weight1); 4428 if(G_test1->m[0] != NULL && maxlengthpoly(G_test1) < maxlengthpoly(G_test)) //if(IDELEMS(G_test1) < IDELEMS(G_test))4429 { 4430 if(G_test2->m[0] != NULL && maxlengthpoly(G_test2) < maxlengthpoly(G_test1)) //if(IDELEMS(G_test2) < IDELEMS(G_test1))4444 if(G_test1->m[0] != NULL && maxlengthpoly(G_test1) < maxlengthpoly(G_test)) 4445 { 4446 if(G_test2->m[0] != NULL && maxlengthpoly(G_test2) < maxlengthpoly(G_test1)) 4431 4447 { 4432 4448 for(i=0; i<nV; i++) … … 4445 4461 else 4446 4462 { 4447 if(G_test2->m[0] != NULL && maxlengthpoly(G_test2) < maxlengthpoly(G_test)) //if(IDELEMS(G_test2) < IDELEMS(G_test)) // |G_test2| < |G_test| <= |G_test1|4463 if(G_test2->m[0] != NULL && maxlengthpoly(G_test2) < maxlengthpoly(G_test)) 4448 4464 { 4449 4465 for(i=0; i<nV; i++) … … 4465 4481 { 4466 4482 Overflow_Error = FALSE; 4467 if(G_test2->m[0] != NULL && maxlengthpoly(G_test2) < maxlengthpoly(G_test)) //if(IDELEMS(G_test2) < IDELEMS(G_test))4483 if(G_test2->m[0] != NULL && maxlengthpoly(G_test2) < maxlengthpoly(G_test)) 4468 4484 { 4469 4485 for(i=1; i<nV; i++) … … 4480 4496 } 4481 4497 } 4482 //PrintS("\n MWalkRandomNextWeight: Ende ok!\n"); 4498 4483 4499 idDelete(&G_test); 4484 4500 idDelete(&G_test2); … … 5403 5419 Set_Error(FALSE); 5404 5420 Overflow_Error = FALSE; 5405 //BOOLEAN endwalks = FALSE;5421 BOOLEAN endwalks = FALSE; 5406 5422 #ifdef TIME_TEST 5407 5423 clock_t tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0; … … 5422 5438 intvec* curr_weight = new intvec(nV); 5423 5439 intvec* target_weight = new intvec(nV); 5424 intvec* exivlp = Mivlp(nV);5425 5440 intvec* next_weight= new intvec(nV); 5426 /* 5427 intvec* tmp_weight = new intvec(nV); 5428 for(i=0; i<nV; i++) 5429 { 5430 (*tmp_weight)[i] = (*target_M)[i]; 5431 } 5432 */ 5441 5433 5442 for(i=0; i<nV; i++) 5434 5443 { … … 5476 5485 5477 5486 nwalk = 0; 5487 5488 #ifdef TIME_TEST 5489 to = clock(); 5490 #endif 5491 Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector" 5492 #ifdef TIME_TEST 5493 tif = tif + clock()-to; //time for computing initial form ideal 5494 #endif 5495 5478 5496 while(1) 5479 5497 { 5480 5498 nwalk ++; 5481 5499 nstep ++; 5482 #ifdef TIME_TEST5483 to = clock();5484 #endif5485 5486 Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector"5487 //polylength = 1 if there is a polynomial in Gomega with at least 3 monomials and 0 otherwise5488 polylength = lengthpoly(Gomega);5489 #ifdef TIME_TEST5490 tif = tif + clock()-to; //time for computing initial form ideal5491 #endif5492 //#ifdef CHECK_IDEAL_MWALK5493 5500 if(printout > 1) 5494 5501 { 5495 5502 idString(Gomega,"//** Mrwalk: Gomega"); 5496 5503 } 5497 //#endif5498 // test whether target cone is reached5499 /* if(test_w_in_ConeCC(G,target_weight) == 1)5500 {5501 endwalks = TRUE;5502 }*/5503 5504 if(reduction == 0) 5504 5505 { 5505 5506 5506 FF = middleOfCone(G,Gomega); 5507 5508 5507 if(FF != NULL) 5509 5508 { … … 5541 5540 { 5542 5541 newRing = VMrDefault(curr_weight); // define a new ring with ordering "(a(curr_weight),lp) 5543 //newRing = VMrRefine(curr_weight,target_weight); //define a new ring with ordering "(a(curr_weight),Wp(target_weight))"5544 5542 } 5545 5543 else … … 5612 5610 rChangeCurrRing(targetRing); 5613 5611 G = idrMoveR(G,newRing,currRing); 5612 5614 5613 // test whether target cone is reached 5615 5614 if(reduction !=0 && test_w_in_ConeCC(G,curr_weight) == 1) … … 5623 5622 baseRing = currRing; 5624 5623 5625 5626 5624 NEXT_VECTOR: 5627 5625 #ifdef TIME_TEST … … 5629 5627 #endif 5630 5628 next_weight = MwalkNextWeightCC(curr_weight,target_weight,G); 5629 #ifdef TIME_TEST 5630 tnw = tnw + clock() - to; 5631 #endif 5632 5633 #ifdef TIME_TEST 5634 to = clock(); 5635 #endif 5636 Gomega = MwalkInitialForm(G, next_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector" 5637 #ifdef TIME_TEST 5638 tif = tif + clock()-to; //time for computing initial form ideal 5639 #endif 5640 5641 //polylength = 1 if there is a polynomial in Gomega with at least 3 monomials and 0 otherwise 5642 polylength = lengthpoly(Gomega); 5631 5643 if(polylength > 0) 5632 5644 { … … 5634 5646 //low-dimensional facet of the cone 5635 5647 delete next_weight; 5648 #ifdef TIME_TEST 5649 to = clock(); 5650 #endif 5636 5651 next_weight = MWalkRandomNextWeight(G, curr_weight, target_weight, weight_rad, pert_deg); 5637 }5638 5652 #ifdef TIME_TEST 5639 5653 tnw = tnw + clock() - to; 5640 5654 #endif 5655 idDelete(&Gomega); 5656 #ifdef TIME_TEST 5657 to = clock(); 5658 #endif 5659 Gomega = MwalkInitialForm(G, next_weight); 5660 #ifdef TIME_TEST 5661 tif = tif + clock()-to; //time for computing initial form ideal 5662 #endif 5663 } 5664 5665 // test whether target weight vector is reached 5666 if(MivComp(next_weight, ivNull) == 1 || MivComp(target_weight,curr_weight) == 1) 5667 { 5668 baseRing = currRing; 5669 delete next_weight; 5670 break; 5671 } 5672 5641 5673 //#ifdef PRINT_VECTORS 5642 5674 if(printout > 0) … … 5645 5677 } 5646 5678 //#endif 5647 if(MivComp(next_weight, ivNull) == 1 || MivComp(target_weight,curr_weight) == 1)// || endwalks == TRUE)5648 {/*5649 //#ifdef CHECK_IDEAL_MWALK5650 if(printout > 0)5651 {5652 PrintS("\n//** Mrwalk: entering last cone.\n");5653 }5654 //#endif5655 5656 Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector"5657 if(target_M->length() == nV)5658 {5659 newRing = VMrDefault(target_weight); // define a new ring with ordering "(a(curr_weight),lp)5660 }5661 else5662 {5663 newRing = VMatrDefault(target_M);5664 }5665 rChangeCurrRing(newRing);5666 Gomega1 = idrMoveR(Gomega, baseRing,currRing);5667 idDelete(&Gomega);5668 //#ifdef CHECK_IDEAL_MWALK5669 if(printout > 1)5670 {5671 idString(Gomega1, "//** Mrwalk: Gomega");5672 }5673 PrintS("\n //** Mrwalk: kStd(Gomega)");5674 //#endif5675 M = kStd(Gomega1,NULL,testHomog,NULL,NULL,0,0,NULL);5676 //#ifdef CHECK_IDEAL_MWALK5677 if(printout > 1)5678 {5679 idString(M,"//** Mrwalk: M");5680 }5681 //#endif5682 rChangeCurrRing(baseRing);5683 M1 = idrMoveR(M, newRing,currRing);5684 idDelete(&M);5685 Gomega2 = idrMoveR(Gomega1, newRing,currRing);5686 idDelete(&Gomega1);5687 //PrintS("\n //** Mrwalk: MLifttwoIdeal");5688 F = MLifttwoIdeal(Gomega2, M1, G);5689 //#ifdef CHECK_IDEAL_MWALK5690 if(printout > 2)5691 {5692 idString(F,"//** Mrwalk: F");5693 }5694 //#endif5695 idDelete(&Gomega2);5696 idDelete(&M1);5697 rChangeCurrRing(newRing); // change the ring to newRing5698 G = idrMoveR(F,baseRing,currRing);5699 idDelete(&F);5700 baseRing = currRing;5701 si_opt_1 = save1; //set original options, e. g. option(RedSB)5702 idSkipZeroes(G);5703 #ifdef TIME_TEST5704 to = clock();5705 #endif5706 //PrintS("\n //**Mrwalk: Interreduce");5707 //interreduce the Groebner basis <G> w.r.t. currRing5708 //G = kInterRedCC(G,NULL);5709 #ifdef TIME_TEST5710 tred = tred + clock() - to;5711 #endif5712 idSkipZeroes(G);5713 delete next_weight;*/5714 break;5715 }5716 5679 5717 5680 for(i=nV-1; i>=0; i--) 5718 5681 { 5719 //(*tmp_weight)[i] = (*curr_weight)[i];5720 5682 (*curr_weight)[i] = (*next_weight)[i]; 5721 5683 } … … 5727 5689 idDelete(&G); 5728 5690 si_opt_1 = save1; //set original options, e. g. option(RedSB) 5729 //delete tmp_weight;5730 5691 delete ivNull; 5731 delete exivlp;5732 5692 #ifndef BUCHBERGER_ALG 5733 5693 delete last_omega; … … 6007 5967 if(reduction == 0 && nstep > 1) 6008 5968 { 5969 /* 6009 5970 // check whether weight vector is in the interior of the cone 6010 5971 while(1) … … 6036 5997 } 6037 5998 } 5999 */ 6000 FF = middleOfCone(G,Gomega); 6001 if(FF != NULL) 6002 { 6003 idDelete(&G); 6004 G = idCopy(FF); 6005 idDelete(&FF); 6006 goto NEXT_VECTOR; 6007 } 6038 6008 } 6039 6009 … … 6157 6127 break; 6158 6128 6129 NEXT_VECTOR: 6159 6130 to=clock(); 6160 6131 // compute a next weight vector … … 6289 6260 { 6290 6261 si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis 6291 //si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions 6292 //si_opt_1|=(Sy_bit(OPT_REDTAIL)|Sy_bit(OPT_REDSB)); 6262 si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions 6293 6263 } 6294 6264 Set_Error(FALSE); … … 6429 6399 ivString(target_weight, "//** Mprwalk: new target weight"); 6430 6400 } 6401 6402 #ifdef TIME_TEST 6403 to = clock(); 6404 #endif 6405 Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector" 6406 #ifdef TIME_TEST 6407 tif = tif + clock()-to; //time for computing initial form ideal 6408 #endif 6409 6431 6410 while(1) 6432 6411 { 6433 6412 nstep ++; 6434 6413 to = clock(); 6435 // compute an initial form ideal of <G> w.r.t. the weight vector 6436 // "curr_weight" 6437 Gomega = MwalkInitialForm(G, curr_weight); 6414 // compute an initial form ideal of G w.r.t. the weight vector "curr_weight" 6415 /* Gomega = MwalkInitialForm(G, curr_weight); 6438 6416 polylength = lengthpoly(Gomega); 6417 */ 6439 6418 //#ifdef CHECK_IDEAL_MWALK 6440 6419 if(printout > 1) … … 6446 6425 if(reduction == 0 && nstep > 1) 6447 6426 { 6427 /* 6448 6428 // check whether weight vector is in the interior of the cone 6449 6429 while(1) … … 6475 6455 } 6476 6456 } 6457 */ 6458 FF = middleOfCone(G,Gomega); 6459 if(FF != NULL) 6460 { 6461 idDelete(&G); 6462 G = idCopy(FF); 6463 idDelete(&FF); 6464 goto NEXT_VECTOR; 6465 } 6477 6466 } 6478 6467 … … 6485 6474 } 6486 6475 #endif 6487 6488 tif = tif + clock()-to;6489 6476 6490 6477 #ifndef BUCHBERGER_ALG … … 6603 6590 break; 6604 6591 6592 Print("\n Next weight"); 6593 NEXT_VECTOR: 6594 #ifdef TIME_TEST 6595 to = clock(); 6596 #endif 6597 next_weight = next_weight = MkInterRedNextWeight(curr_weight,target_weight, G); 6598 #ifdef TIME_TEST 6599 tnw = tnw + clock() - to; 6600 #endif 6601 6602 #ifdef TIME_TEST 6603 to = clock(); 6604 #endif 6605 Gomega = MwalkInitialForm(G, next_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector" 6606 #ifdef TIME_TEST 6607 tif = tif + clock()-to; //time for computing initial form ideal 6608 #endif 6609 6610 //polylength = 1 if there is a polynomial in Gomega with at least 3 monomials and 0 otherwise 6611 polylength = lengthpoly(Gomega); 6612 if(polylength > 0) 6613 { 6614 Print("\n there is a polynomial in Gomega with at least 3 monomials"); 6615 //low-dimensional facet of the cone 6616 delete next_weight; 6617 #ifdef TIME_TEST 6618 to = clock(); 6619 #endif 6620 next_weight = MWalkRandomNextWeight(G, curr_weight, target_weight, weight_rad, op_deg); 6621 #ifdef TIME_TEST 6622 tnw = tnw + clock() - to; 6623 #endif 6624 idDelete(&Gomega); 6625 #ifdef TIME_TEST 6626 to = clock(); 6627 #endif 6628 Gomega = MwalkInitialForm(G, next_weight); 6629 #ifdef TIME_TEST 6630 tif = tif + clock()-to; //time for computing initial form ideal 6631 #endif 6632 } 6633 6634 /* 6605 6635 to=clock(); 6606 6607 6636 next_weight = MkInterRedNextWeight(curr_weight,target_weight, G); 6608 6637 if(polylength > 0) … … 6616 6645 } 6617 6646 tnw=tnw+clock()-to; 6647 */ 6618 6648 //#ifdef PRINT_VECTORS 6619 6649 if(printout > 0) … … 6626 6656 { 6627 6657 ntwC = 0; 6628 //ntestomega = 1;6629 6658 //Print("\n// ring r%d = %s;\n", nstep, rString(currRing)); 6630 6659 //idElements(G, "G"); … … 6716 6745 Eresult = idrMoveR(eF1, exTargetRing,currRing); 6717 6746 } 6718 else{ 6747 else 6748 { 6719 6749 rChangeCurrRing(XXRing); 6720 6750 Eresult = idrMoveR(F1, TargetRing,currRing); 6721 6751 } 6722 6752 } 6723 else { 6753 else 6754 { 6724 6755 rChangeCurrRing(XXRing); 6725 6756 Eresult = idrMoveR(G, newRing,currRing); … … 7287 7318 if(polylength > 0 && G->m[0] != NULL) 7288 7319 { 7289 7290 PrintS("\n**// rec_r_fractal_call: there is a polynomial in Gomega with at least 3 monomials, low-dimensional facet of the cone.\n"); 7291 7320 if(printout > 0) 7321 { 7322 PrintS("\n**// rec_r_fractal_call: there is a polynomial in Gomega with at least 3 monomials, low-dimensional facet of the cone.\n"); 7323 } 7292 7324 delete next_vect; 7293 7325 next_vect = MWalkRandomNextWeight(G,omega,omega2,weight_rad,nlev); 7294 if(isNegNolVector(next_vect) ==1)7326 if(isNegNolVector(next_vect) == 1) 7295 7327 { 7296 7328 delete next_vect; … … 7376 7408 delete next_vect; 7377 7409 next_vect = MWalkRandomNextWeight(G,omega,omega2,weight_rad,nlev); 7378 if(isNegNolVector(next_vect) ==1)7410 if(isNegNolVector(next_vect) == 1) 7379 7411 { 7380 7412 delete next_vect;
Note: See TracChangeset
for help on using the changeset viewer.