6390{
6393 {
6396 }
6399
6400#ifdef TIME_TEST
6401 clock_t tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0;
6402 xtextra=0;
6403 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0;
6404 tinput = clock();
6405
6406 clock_t tim;
6407#endif
6409 int i, ntwC=1, ntestw=1, nV =
currRing->N;
6410
6411
6412 if(weight_rad < 0)
6413 {
6416 }
6417
6418
6419 if(op_deg < 1 || tp_deg < 1 || op_deg > nV || tp_deg > nV)
6420 {
6421 WerrorS(
"Invalid perturbation degree.\n");
6423 }
6424
6426
6427 ideal Gomega,
M, F, FF,
G, Gomega1, Gomega2, M1,
F1,Eresult,ssG;
6428 ring newRing, oldRing, TargetRing;
6436 {
6437 (*curr_weight)[
i] = (*orig_M)[
i];
6438 (*target_weight)[
i] = (*target_M)[
i];
6439 }
6440 intvec* orig_target = target_weight;
6441 intvec* pert_target_vector = target_weight;
6444#ifndef BUCHBERGER_ALG
6446#endif
6448
6449
6451 for(
i=nV-1;
i>0;
i--)
6452 (*last_omega)[
i] = 1;
6453 (*last_omega)[0] = 10000;
6454
6456
6457
6458 if(orig_M->
length() == nV)
6459 {
6460 if(
MivComp(curr_weight, iv_dp) == 1)
6461 {
6462#ifdef TIME_TEST
6463 to = clock();
6464#endif
6466#ifdef TIME_TEST
6467 tostd = clock()-to;
6468#endif
6469 if(op_deg != 1)
6470 {
6473 }
6474 }
6475 else
6476 {
6477
6480 else
6482
6484#ifdef TIME_TEST
6485 to = clock();
6486#endif
6488#ifdef TIME_TEST
6489 tostd = clock()-to;
6490#endif
6491 if(op_deg != 1)
6492 {
6495 }
6496 }
6497 }
6498 else
6499 {
6502#ifdef TIME_TEST
6503 to = clock();
6504#endif
6506#ifdef TIME_TEST
6507 tostd = clock()-to;
6508#endif
6509 if(op_deg != 1)
6510 {
6512 }
6513 }
6514
6515 delete iv_dp;
6516 if(op_deg != 1) delete iv_M_dp;
6517
6519
6520
6521 if(target_M->
length() == nV)
6522 {
6523 if(tp_deg > 1 && tp_deg <= nV)
6524 {
6527 else
6529
6532 if(
MivSame(target_weight, exivlp) == 1)
6533 {
6536 }
6537 else
6538 {
6541 }
6542 delete iv_M_lp;
6543 pert_target_vector = target_weight;
6546 }
6547 }
6548 else
6549 {
6550 if(tp_deg > 1 && tp_deg <= nV)
6551 {
6556 }
6557 }
6558 if(printout > 0)
6559 {
6560 Print(
"\n//** Mprwalk: Random Perturbation Walk of degree (%d,%d):",op_deg,tp_deg);
6561 ivString(curr_weight,
"//** Mprwalk: new current weight");
6562 ivString(target_weight,
"//** Mprwalk: new target weight");
6563 }
6564
6565#ifdef TIME_TEST
6566 to = clock();
6567#endif
6569#ifdef TIME_TEST
6570 tif = tif + clock()-to;
6571#endif
6572
6573 while(1)
6574 {
6576#ifdef CHECK_IDEAL_MWALK
6577 if(printout > 1)
6578 {
6579 idString(Gomega,
"//** Mprwalk: Gomega");
6580 }
6581#endif
6582
6584 {
6587 {
6591 goto NEXT_VECTOR;
6592 }
6593 }
6594
6595#ifdef ENDWALKS
6596 if(endwalks ==
TRUE)
6597 {
6598 if(printout > 0)
6599 {
6601
6602
6603 }
6604 }
6605#endif
6606
6607#ifndef BUCHBERGER_ALG
6608 if(isNolVector(curr_weight) == 0)
6610 else
6612#endif
6613
6615
6616 if(target_M->
length() == nV)
6617 {
6618
6619
6620
6621
6622
6623
6625 }
6626 else
6627 {
6629 }
6632#ifdef ENDWALKS
6633 if(endwalks ==
TRUE)
6634 {
6635 if(printout > 0)
6636 {
6638
6639
6640
6641
6642 PrintS(
"\n// compute a rGB of Gw:\n");
6643 }
6644#ifndef BUCHBERGER_ALG
6646#endif
6647 }
6648#endif
6649#ifdef TIME_TEST
6650 tim = clock();
6651 to = clock();
6652#endif
6653
6654#ifdef BUCHBERGER_ALG
6656#else
6658 delete hilb_func;
6659#endif
6660#ifdef CHECK_IDEAL_MWALK
6661 if(printout > 2)
6662 {
6664 }
6665#endif
6666#ifdef TIME_TEST
6667 if(endwalks ==
TRUE)
6668 {
6669 xtstd = xtstd+clock()-to;
6670#ifdef ENDWALKS
6671 Print(
"\n// time for the last std(Gw) = %.2f sec\n",
6672 ((double) clock())/1000000 -((double)tim) /1000000);
6673#endif
6674 }
6675 else
6676 tstd=tstd+clock()-to;
6677#endif
6678
6682#ifdef TIME_TEST
6683 to=clock();
6684#endif
6685
6686
6687
6689#ifdef TIME_TEST
6690 if(endwalks ==
FALSE)
6691 tlift = tlift+clock()-to;
6692 else
6693 xtlift=clock()-to;
6694#endif
6695#ifdef CHECK_IDEAL_MWALK
6696 if(printout > 2)
6697 {
6699 }
6700#endif
6701
6705
6706
6709 {
6711 }
6712 else
6713 {
6715 if(printout > 2)
6716 {
6717 PrintS(
"\n //** Mprwalk: reduce the Groebner basis.\n");
6718 }
6719#ifdef TIME_TEST
6720 to=clock();
6721#endif
6723#ifdef TIME_TEST
6724 if(endwalks ==
FALSE)
6725 tred = tred+clock()-to;
6726 else
6727 xtred=clock()-to;
6728#endif
6730 }
6731
6732 if(endwalks ==
TRUE)
6733 break;
6734
6735 NEXT_VECTOR:
6736#ifdef TIME_TEST
6737 to = clock();
6738#endif
6740#ifdef TIME_TEST
6741 tnw = tnw + clock() - to;
6742#endif
6743
6744#ifdef TIME_TEST
6745 to = clock();
6746#endif
6747
6749#ifdef TIME_TEST
6750 tif = tif + clock()-to;
6751#endif
6752
6753
6755 {
6756 if(printout > 1)
6757 {
6758 PrintS(
"\n Mpwalk: there is a polynomial in Gomega with at least 3 monomials.\n");
6759 }
6760
6761 delete next_weight;
6762 if(target_M->
length() == nV)
6763 {
6765 }
6766 else
6767 {
6769 }
6770#ifdef TIME_TEST
6771 to = clock();
6772#endif
6774#ifdef TIME_TEST
6775 tnw = tnw + clock() - to;
6776#endif
6778#ifdef TIME_TEST
6779 to = clock();
6780#endif
6782#ifdef TIME_TEST
6783 tif = tif + clock()-to;
6784#endif
6785 delete iv_M;
6786 }
6787
6788#ifdef PRINT_VECTORS
6789 if(printout > 0)
6790 {
6791 MivString(curr_weight, target_weight, next_weight);
6792 }
6793#endif
6794
6796 {
6797 ntwC = 0;
6798
6799
6800 delete next_weight;
6801 goto FINISH_160302;
6802 }
6803 if(
MivComp(next_weight, ivNull) == 1){
6805 delete next_weight;
6806
6807 break;
6808 }
6809 if(
MivComp(next_weight, target_weight) == 1)
6811
6812 for(
i=nV-1;
i>=0;
i--)
6813 (*curr_weight)[
i] = (*next_weight)[
i];
6814
6815 delete next_weight;
6816 }
6817
6818 if(tp_deg != 1)
6819 {
6820 FINISH_160302:
6821 if(target_M->
length() == nV)
6822 {
6823 if(
MivSame(orig_target, exivlp) == 1)
6826 else
6828 else
6831 else
6833 }
6834 else
6835 {
6837 }
6840
6841
6842 if(ntwC != 0)
6843 {
6845 }
6846 if(ntestw != 1 || ntwC == 0)
6847 {
6848 if(ntestw != 1 && printout > 2)
6849 {
6850#ifdef PRINT_VECTORS
6851 ivString(pert_target_vector,
"tau");
6852#endif
6853 PrintS(
"\n// **Mprwalk: perturbed target vector doesn't stay in cone.");
6855
6856 }
6857
6858#ifdef TIME_TEST
6859 to=clock();
6860#endif
6861 ideal eF1;
6862 if(nP == 0 || tp_deg == 1 ||
MivSame(orig_target, exivlp) != 1 || target_M->
length() != nV)
6863 {
6864 if(printout > 2)
6865 {
6866 PrintS(
"\n// ** Mprwalk: Call \"std\" to compute a Groebner basis.\n");
6867 }
6870 }
6871 else
6872 {
6873 if(printout > 2)
6874 {
6875 PrintS(
"\n// **Mprwalk: Call \"LastGB\" to compute a Groebner basis.\n");
6876 }
6879 eF1 =
LastGB(
F2, curr_weight, tp_deg-1);
6881 }
6882#ifdef TIME_TEST
6883 xtextra=clock()-to;
6884#endif
6886
6889 }
6890 else
6891 {
6894 }
6895 }
6896 else
6897 {
6900 }
6902 delete ivNull;
6903 if(tp_deg != 1)
6904 delete target_weight;
6905
6906 if(op_deg != 1 )
6907 delete curr_weight;
6908
6909 delete exivlp;
6910 delete last_omega;
6911
6912#ifdef TIME_TEST
6913 TimeStringFractal(tinput, tostd, tif+xtif, tstd+xtstd,0, tlift+xtlift, tred+xtred,
6914 tnw+xtnw);
6915
6916
6917
6918#endif
6919
6920 if(printout > 0)
6921 {
6922 Print(
"\n//** Mprwalk: Perturbation Walk took %d steps.\n",
nstep);
6923 }
6924 return(Eresult);
6925}
void F2(int a2, int &r2)
F2.
static int lengthpoly(ideal G)
static ideal middleOfCone(ideal G, ideal Gomega)
static intvec * MWalkRandomNextWeight(ideal G, intvec *orig_M, intvec *target_weight, int weight_rad, int pert_deg)
intvec * MivMatrixOrderRefine(intvec *iv, intvec *iw)
static ideal LastGB(ideal G, intvec *curr_weight, int tp_deg)
static void idString(ideal L, const char *st)