Changeset 2474


Ignore:
Timestamp:
Jan 21, 2019 4:11:14 PM (3 months ago)
Author:
unxusr
Message:

fixed modk cuts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cbc/examples/modk.c

    r2473 r2474  
    1616#include <stdlib.h>
    1717#include <limits.h>
     18#include <assert.h>
    1819#include <float.h>
    1920#include <ctype.h>
     
    3435void cutcallback( void *osiSolver, void *osiCuts, void *appData )
    3536{
    36   printf("entered callback");
     37  printf("entered callback\n");
    3738  int m = Osi_getNumRows( osiSolver );
    3839  int n = Osi_getNumCols( osiSolver );
     
    103104
    104105    // removing those which are divisors of larger values
    105     for ( int j=0 ; (j<nz-1) ; ++j )
    106     {
    107       for ( int jl=j+1 ; (jl<nz) ; ++jl )
    108       {
     106    for ( int j=0 ; (j<ndiff-1) ; ++j )
     107    {
     108      for ( int jl=j+1 ; (jl<ndiff) ; ++jl )
     109      {
     110        if (!dcoef[j])
     111          continue;
    109112        if ( dcoef[jl] % dcoef[j] == 0 )
    110113        {
     
    166169            continue;
    167170
    168           OsiCuts_addRowCut( osiCuts, nz, cidx, coef, 'L', rhsCut );
     171          OsiCuts_addRowCut( osiCuts, nzCut, cidx, coef, 'L', rhsCut );
    169172        } // constraint in the form <=
    170173      } // every numerator < k
     
    234237  double sumLHS = 0.0;
    235238
    236   *nzCut = 0;
     239  (*nzCut) = 0;
    237240  for ( int j=0 ; j<nz ; ++j )
    238241  {
    239242    int col = rIdx[j];
     243    assert( col >= 0 && col<Osi_getNumCols(osiSolver) );
    240244
    241245    int cc = (icoef[j]*num)/den;
     
    248252    sumLHS += ((double)cc) * x[col];
    249253
    250     ++(*nzCut);
     254    (*nzCut)++;
    251255  }
    252256
     
    268272  Cbc_readMps( mip, argv[1] );
    269273
     274  Cbc_setParameter( mip, "cuts", "off" );
     275  Cbc_setParameter( mip, "gomory", "ifmove" );
     276  Cbc_setParameter( mip, "preprocess", "off" );
     277
    270278  Cbc_addCutCallback( mip,  cutcallback, "modk", NULL );
     279
    271280
    272281  Cbc_solve( mip );
Note: See TracChangeset for help on using the changeset viewer.