6391{
6394 {
6397 }
6400
6401#ifdef TIME_TEST
6402 clock_t tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0;
6403 xtextra=0;
6404 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0;
6405 tinput = clock();
6406
6407 clock_t tim;
6408#endif
6410 int i, ntwC=1, ntestw=1, nV =
currRing->N;
6411
6412
6413 if(weight_rad < 0)
6414 {
6417 }
6418
6419
6420 if(op_deg < 1 || tp_deg < 1 || op_deg > nV || tp_deg > nV)
6421 {
6422 WerrorS(
"Invalid perturbation degree.\n");
6424 }
6425
6427
6428 ideal Gomega,
M, F, FF,
G, Gomega1, Gomega2, M1,
F1,Eresult,ssG;
6429 ring newRing, oldRing, TargetRing;
6437 {
6438 (*curr_weight)[
i] = (*orig_M)[
i];
6439 (*target_weight)[
i] = (*target_M)[
i];
6440 }
6441 intvec* orig_target = target_weight;
6442 intvec* pert_target_vector = target_weight;
6445#ifndef BUCHBERGER_ALG
6447#endif
6449
6450
6452 for(
i=nV-1;
i>0;
i--)
6453 (*last_omega)[
i] = 1;
6454 (*last_omega)[0] = 10000;
6455
6457
6458
6459 if(orig_M->
length() == nV)
6460 {
6461 if(
MivComp(curr_weight, iv_dp) == 1)
6462 {
6463#ifdef TIME_TEST
6464 to = clock();
6465#endif
6467#ifdef TIME_TEST
6468 tostd = clock()-to;
6469#endif
6470 if(op_deg != 1)
6471 {
6474 }
6475 }
6476 else
6477 {
6478
6481 else
6483
6485#ifdef TIME_TEST
6486 to = clock();
6487#endif
6489#ifdef TIME_TEST
6490 tostd = clock()-to;
6491#endif
6492 if(op_deg != 1)
6493 {
6496 }
6497 }
6498 }
6499 else
6500 {
6503#ifdef TIME_TEST
6504 to = clock();
6505#endif
6507#ifdef TIME_TEST
6508 tostd = clock()-to;
6509#endif
6510 if(op_deg != 1)
6511 {
6513 }
6514 }
6515
6516 delete iv_dp;
6517 if(op_deg != 1) delete iv_M_dp;
6518
6520
6521
6522 if(target_M->
length() == nV)
6523 {
6524 if(tp_deg > 1 && tp_deg <= nV)
6525 {
6528 else
6530
6533 if(
MivSame(target_weight, exivlp) == 1)
6534 {
6537 }
6538 else
6539 {
6542 }
6543 delete iv_M_lp;
6544 pert_target_vector = target_weight;
6547 }
6548 }
6549 else
6550 {
6551 if(tp_deg > 1 && tp_deg <= nV)
6552 {
6557 }
6558 }
6559 if(printout > 0)
6560 {
6561 Print(
"\n//** Mprwalk: Random Perturbation Walk of degree (%d,%d):",op_deg,tp_deg);
6562 ivString(curr_weight,
"//** Mprwalk: new current weight");
6563 ivString(target_weight,
"//** Mprwalk: new target weight");
6564 }
6565
6566#ifdef TIME_TEST
6567 to = clock();
6568#endif
6570#ifdef TIME_TEST
6571 tif = tif + clock()-to;
6572#endif
6573
6574 while(1)
6575 {
6577#ifdef CHECK_IDEAL_MWALK
6578 if(printout > 1)
6579 {
6580 idString(Gomega,
"//** Mprwalk: Gomega");
6581 }
6582#endif
6583
6585 {
6588 {
6592 goto NEXT_VECTOR;
6593 }
6594 }
6595
6596#ifdef ENDWALKS
6597 if(endwalks ==
TRUE)
6598 {
6599 if(printout > 0)
6600 {
6602
6603
6604 }
6605 }
6606#endif
6607
6608#ifndef BUCHBERGER_ALG
6609 if(isNolVector(curr_weight) == 0)
6611 else
6613#endif
6614
6616
6617 if(target_M->
length() == nV)
6618 {
6619
6620
6621
6622
6623
6624
6626 }
6627 else
6628 {
6630 }
6633#ifdef ENDWALKS
6634 if(endwalks ==
TRUE)
6635 {
6636 if(printout > 0)
6637 {
6639
6640
6641
6642
6643 PrintS(
"\n// compute a rGB of Gw:\n");
6644 }
6645#ifndef BUCHBERGER_ALG
6647#endif
6648 }
6649#endif
6650#ifdef TIME_TEST
6651 tim = clock();
6652 to = clock();
6653#endif
6654
6655#ifdef BUCHBERGER_ALG
6657#else
6659 delete hilb_func;
6660#endif
6661#ifdef CHECK_IDEAL_MWALK
6662 if(printout > 2)
6663 {
6665 }
6666#endif
6667#ifdef TIME_TEST
6668 if(endwalks ==
TRUE)
6669 {
6670 xtstd = xtstd+clock()-to;
6671#ifdef ENDWALKS
6672 Print(
"\n// time for the last std(Gw) = %.2f sec\n",
6673 ((double) clock())/1000000 -((double)tim) /1000000);
6674#endif
6675 }
6676 else
6677 tstd=tstd+clock()-to;
6678#endif
6679
6683#ifdef TIME_TEST
6684 to=clock();
6685#endif
6686
6687
6688
6690#ifdef TIME_TEST
6691 if(endwalks ==
FALSE)
6692 tlift = tlift+clock()-to;
6693 else
6694 xtlift=clock()-to;
6695#endif
6696#ifdef CHECK_IDEAL_MWALK
6697 if(printout > 2)
6698 {
6700 }
6701#endif
6702
6706
6707
6710 {
6712 }
6713 else
6714 {
6716 if(printout > 2)
6717 {
6718 PrintS(
"\n //** Mprwalk: reduce the Groebner basis.\n");
6719 }
6720#ifdef TIME_TEST
6721 to=clock();
6722#endif
6724#ifdef TIME_TEST
6725 if(endwalks ==
FALSE)
6726 tred = tred+clock()-to;
6727 else
6728 xtred=clock()-to;
6729#endif
6731 }
6732
6733 if(endwalks ==
TRUE)
6734 break;
6735
6736 NEXT_VECTOR:
6737#ifdef TIME_TEST
6738 to = clock();
6739#endif
6741#ifdef TIME_TEST
6742 tnw = tnw + clock() - to;
6743#endif
6744
6745#ifdef TIME_TEST
6746 to = clock();
6747#endif
6748
6750#ifdef TIME_TEST
6751 tif = tif + clock()-to;
6752#endif
6753
6754
6756 {
6757 if(printout > 1)
6758 {
6759 PrintS(
"\n Mpwalk: there is a polynomial in Gomega with at least 3 monomials.\n");
6760 }
6761
6762 delete next_weight;
6763 if(target_M->
length() == nV)
6764 {
6766 }
6767 else
6768 {
6770 }
6771#ifdef TIME_TEST
6772 to = clock();
6773#endif
6775#ifdef TIME_TEST
6776 tnw = tnw + clock() - to;
6777#endif
6779#ifdef TIME_TEST
6780 to = clock();
6781#endif
6783#ifdef TIME_TEST
6784 tif = tif + clock()-to;
6785#endif
6786 delete iv_M;
6787 }
6788
6789#ifdef PRINT_VECTORS
6790 if(printout > 0)
6791 {
6792 MivString(curr_weight, target_weight, next_weight);
6793 }
6794#endif
6795
6797 {
6798 ntwC = 0;
6799
6800
6801 delete next_weight;
6802 goto FINISH_160302;
6803 }
6804 if(
MivComp(next_weight, ivNull) == 1){
6806 delete next_weight;
6807
6808 break;
6809 }
6810 if(
MivComp(next_weight, target_weight) == 1)
6812
6813 for(
i=nV-1;
i>=0;
i--)
6814 (*curr_weight)[
i] = (*next_weight)[
i];
6815
6816 delete next_weight;
6817 }
6818
6819 if(tp_deg != 1)
6820 {
6821 FINISH_160302:
6822 if(target_M->
length() == nV)
6823 {
6824 if(
MivSame(orig_target, exivlp) == 1)
6827 else
6829 else
6832 else
6834 }
6835 else
6836 {
6838 }
6841
6842
6843 if(ntwC != 0)
6844 {
6846 }
6847 if(ntestw != 1 || ntwC == 0)
6848 {
6849 if(ntestw != 1 && printout > 2)
6850 {
6851#ifdef PRINT_VECTORS
6852 ivString(pert_target_vector,
"tau");
6853#endif
6854 PrintS(
"\n// **Mprwalk: perturbed target vector doesn't stay in cone.");
6856
6857 }
6858
6859#ifdef TIME_TEST
6860 to=clock();
6861#endif
6862 ideal eF1;
6863 if(nP == 0 || tp_deg == 1 ||
MivSame(orig_target, exivlp) != 1 || target_M->
length() != nV)
6864 {
6865 if(printout > 2)
6866 {
6867 PrintS(
"\n// ** Mprwalk: Call \"std\" to compute a Groebner basis.\n");
6868 }
6871 }
6872 else
6873 {
6874 if(printout > 2)
6875 {
6876 PrintS(
"\n// **Mprwalk: Call \"LastGB\" to compute a Groebner basis.\n");
6877 }
6880 eF1 =
LastGB(
F2, curr_weight, tp_deg-1);
6882 }
6883#ifdef TIME_TEST
6884 xtextra=clock()-to;
6885#endif
6887
6890 }
6891 else
6892 {
6895 }
6896 }
6897 else
6898 {
6901 }
6903 delete ivNull;
6904 if(tp_deg != 1)
6905 delete target_weight;
6906
6907 if(op_deg != 1 )
6908 delete curr_weight;
6909
6910 delete exivlp;
6911 delete last_omega;
6912
6913#ifdef TIME_TEST
6914 TimeStringFractal(tinput, tostd, tif+xtif, tstd+xtstd,0, tlift+xtlift, tred+xtred,
6915 tnw+xtnw);
6916
6917
6918
6919#endif
6920
6921 if(printout > 0)
6922 {
6923 Print(
"\n//** Mprwalk: Perturbation Walk took %d steps.\n",
nstep);
6924 }
6925 return(Eresult);
6926}
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)