Changeset 2591
 Timestamp:
 Jun 13, 2019 2:57:25 PM (4 months ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/Cbc/test/CInterfaceTest.c
r2587 r2591 375 375 x[i] = x[i1] + n; 376 376 377 Cbc_Model *m = Cbc_newModel();378 379 / / adding variables377 Cbc_Model *model = Cbc_newModel(); 378 379 /* adding variables */ 380 380 k = 0; 381 381 for ( i=0 ; (i<n) ; ++i ) … … 386 386 char name[256]; 387 387 sprintf(name, "x(%d,%d)", i, j); 388 Cbc_addCol(m , name, 0.0, 1.0, 0.0, 1, 0, NULL, NULL);388 Cbc_addCol(model, name, 0.0, 1.0, 0.0, 1, 0, NULL, NULL); 389 389 } 390 390 } … … 393 393 double *coef = malloc(sizeof(double)*n); 394 394 395 / / constraint one per row395 /* constraint one per row */ 396 396 for ( i=0 ; (i<n) ; ++i ) 397 397 { … … 403 403 char name[256]; 404 404 sprintf(name, "row(%d)", i); 405 Cbc_addRow(m , name, n, idx, coef, 'E', 1.0);406 } 407 408 / / constraint one per column405 Cbc_addRow(model, name, n, idx, coef, 'E', 1.0); 406 } 407 408 /* constraint one per column */ 409 409 for ( j=0 ; (j<n) ; ++j ) 410 410 { … … 416 416 char name[256]; 417 417 sprintf(name, "col(%d)", j); 418 Cbc_addRow(m , name, n, idx, coef, 'E', 1.0);419 } 420 421 / / diagonal418 Cbc_addRow(model, name, n, idx, coef, 'E', 1.0); 419 } 420 421 /* diagonal */ 422 422 p = 0; 423 423 for ( k=2n ; k<(n1) ; ++k, ++p ) … … 438 438 char name[256]; 439 439 sprintf(name, "diag1(%d)", k); 440 Cbc_addRow(m , name, nz, idx, coef, 'L', 1.0);441 } 442 443 / / diagonal/440 Cbc_addRow(model, name, nz, idx, coef, 'L', 1.0); 441 } 442 443 /* diagonal */ 444 444 p = 0; 445 445 for ( k=3 ; k<(n+n) ; ++k, ++p ) … … 460 460 char name[256]; 461 461 sprintf(name, "diag2(%d)", k); 462 Cbc_addRow(m , name, nz, idx, coef, 'L', 1.0);462 Cbc_addRow(model, name, nz, idx, coef, 'L', 1.0); 463 463 } 464 464 465 Cbc_setMaximumSeconds(m , 60);466 int status = Cbc_solve(m );467 const double *xs = Cbc_getColSolution(m );465 Cbc_setMaximumSeconds(model, 60); 466 int status = Cbc_solve(model); 467 const double *xs = Cbc_getColSolution(model); 468 468 if (n<=75) 469 469 { 470 / / should find the optimal for small problems471 assert(Cbc_isProvenOptimal(m ));470 /* should find the optimal for small problems */ 471 assert(Cbc_isProvenOptimal(model)); 472 472 assert(xs); 473 473 } 474 474 if (xs) { 475 / / solution check476 477 // total number of queens 475 /* solution check 476 477 // total number of queens */ 478 478 int nq = 0; 479 479 for ( i=0 ; (i<n) ; ++i ) … … 482 482 nq++; 483 483 assert(nq == n); 484 // one per row485 484 for ( i=0 ; (i<n) ; ++i ) 486 485 { … … 491 490 assert( nq == 1); 492 491 } 493 // one per column494 492 for ( j=0 ; (j<n) ; ++j ) 495 493 { … … 507 505 free(x); 508 506 509 Cbc_deleteModel(m );507 Cbc_deleteModel(model); 510 508 } 511 509
Note: See TracChangeset
for help on using the changeset viewer.