Ignore:
Timestamp:
Sep 13, 2012 12:31:33 PM (7 years ago)
Author:
forrest
Message:

fix a few problems with Aboca

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Clp/src/AbcSimplexDual.cpp

    r1878 r1879  
    208208#define CLEAN_FIXED 0
    209209// Startup part of dual (may be extended to other algorithms)
     210// To force to follow another run put logfile name here and define
     211#define FORCE_FOLLOW
     212//#ifdef FORCE_FOLLOW
     213static FILE * fpFollow = NULL;
     214static const char * forceFile = NULL;
     215static int force_in = -1;
     216static int force_out = -1;
     217static int force_way_in = -1;
     218static int force_way_out = -1;
     219static int force_iterations = 0;
     220int force_argc=0;
     221const char ** force_argv=NULL;
     222#endif
    210223void
    211224AbcSimplexDual::startupSolve()
    212225{
     226#ifdef FORCE_FOLLOW
     227  int ifld;
     228  for (ifld=1;ifld<force_argc;ifld++) {
     229    if (strstr(argv[ifld],".log")) {
     230      forceFile=argv[ifld];
     231      break;
     232    }
     233  }
     234  if (!fpFollow && strlen(forceFile)) {
     235    fpFollow = fopen(forceFile, "r");
     236    assert (fpFollow);
     237  }
     238  if (fpFollow) {
     239    int numberRead= atoi(argv[ifld+1]);
     240    force_iterations=atoi(argv[ifld+1]);
     241    printf("skipping %d iterations and then doing %d\n",numberRead,force_iterations);
     242    for (int iteration=0;iteration<numberRead;iteration++) {
     243      // read to next Clp0102
     244      char temp[300];
     245      while (fgets(temp, 250, fpFollow)) {
     246        if (!strncmp(temp, "dirOut", 6))
     247          break;
     248      }
     249      sscanf(temp+7 , "%d%*s%d%*s%*s%d",
     250             &force_way_out, &force_way_in);
     251      fgets(temp, 250, fpFollow);
     252      char cin, cout;
     253      int whichIteration;
     254      sscanf(temp , "%d%*f%*s%*c%c%d%*s%*c%c%d",
     255             &whichIteration, &cin, &force_in, &cout, &force_out);
     256      assert (whichIterations==iteration+1);
     257      if (cin == 'C')
     258        force_in += numberColumns_;
     259      if (cout == 'C')
     260        force_out += numberColumns_;
     261      printf("Iteration %d will force %d out (way %d) and %d in (way %d)\n",
     262             whichIteration, force_out, force_way_out,force_in,force_way_in);
     263      assert (getInternalStatus(force_out)==basic);
     264      assert (getInternalStatus(force_in)!=basic);
     265      setInternalStatus(force_in,basic);
     266      if (force_way_out==-1)
     267        setInternalStatus(force_out,atUpperBound);
     268      else
     269        setInternalStatus(force_out,atLowerBound);
     270    }
     271    // clean up
     272    int numberBasic=0;
     273    for (int i=0;i<numberTotal_;i++) {
     274      if (getInternalStatus(i)==basic) {
     275        abcPivotVariable_[numberBasic++]=i;
     276      } else if (getInternalStatus(i)==atLowerBound) {
     277        if (abcLower_[i]<-1.0e30) {
     278          abcLower_[i]=abcUpper_[i]-dualBound_;
     279          setFakeLower(i);
     280        }
     281      } else if (getInternalStatus(i)==atUpperBound) {
     282        if (abcUpper_[i]>1.0e30) {
     283          abcUpper_[i]=abcLower_[i]+dualBound_;
     284          setFakeUpper(i);
     285        }
     286      }
     287    }
     288    assert (numberBasic==numberRows_);
     289  }
     290#endif
    213291  // initialize - no values pass and algorithm_ is -1
    214292  // put in standard form (and make row copy)
     
    27072785#endif
    27082786          setFlagged(sequenceOut_);
     2787          lastBadIteration_ = numberIterations_; // say be more cautious
    27092788          // so can't happen immediately again
    27102789          sequenceOut_=-1;
     
    27442823  double savePrimalInfeasibilities=sumPrimalInfeasibilities_;
    27452824  if ((moreSpecialOptions_&16384)!=0&&(moreSpecialOptions_&8192)==0) {
    2746     if (!numberIterations_) {
     2825    if (numberIterations_==baseIteration_) {
    27472826      // If primal feasible and looks suited to primal go to primal
    27482827      if (!sumPrimalInfeasibilities_&&sumDualInfeasibilities_>1.0&&
     
    28472926#endif
    28482927          setFlagged(sequenceOut_);
     2928          lastBadIteration_ = numberIterations_; // say be more cautious
    28492929#if ABC_NORMAL_DEBUG>0
    28502930        } else {
     
    54605540    int saveStatus=problemStatus_;
    54615541    // check update
     5542#if MOVE_REPLACE_PART1A < 0
     5543    checkReplacePart1();
     5544#endif
    54625545    int updateStatus=abcFactorization_->checkReplacePart2(pivotRow_,btranAlpha_,alpha_,ftAlpha_);
    54635546#if ABC_DEBUG
     
    56265709#endif
    56275710        setFlagged(sequenceOut_);
     5711        lastBadIteration_ = numberIterations_; // say be more cautious
    56285712        // so can't happen immediately again
    56295713        sequenceOut_=-1;
Note: See TracChangeset for help on using the changeset viewer.