Changeset 333


Ignore:
Timestamp:
Nov 11, 2009 5:40:32 PM (10 years ago)
Author:
bjarni
Message:

Update example.c by removing LoadNamesType?, add optimalValue in printout, and test for sosCount == 0 plus fixing whitespace issues

Location:
stable/1.4/CoinMP
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • stable/1.4/CoinMP/examples/example.c

    • Property svn:keywords set to Id
    r282 r333  
    11
    22/* example.c */
     3
     4// $Id$
    35
    46#include <stdlib.h>
     
    3739        return 0;
    3840}
    39 
    4041
    4142
     
    5657        objectValue =  CoinGetObjectValue(hProb);
    5758     
    58         fprintf(stdout, "\n---------------------------------------\n");
     59        fprintf(stdout, "\n---------------------------------------\n");
    5960        fprintf(stdout, "Problem Name:    %s\n", problemName);
    6061        fprintf(stdout, "Solution Result: %s\n", solutionText );
     
    6263        fprintf(stdout, "Optimal Value:   %lg\n", objectValue);
    6364        fprintf(stdout, "---------------------------------------\n");
    64      
     65
    6566        colCount = CoinGetColCount(hProb);
    6667        xValues = (double* )malloc(colCount * sizeof(double));
     
    8687          double* lowerBounds, double* upperBounds, char* rowType, double* rhsValues, double* rangeValues,
    8788          int* matrixBegin, int* matrixCount, int* matrixIndex, double* matrixValues, char** colNames,
    88           char** rowNames, char* objectName, double* initValues, char* columnType, int LoadNamesType)
     89          char** rowNames, char* objectName, double* initValues, char* columnType)
    8990{
    9091        HPROB hProb;
     
    9293        char filename[260];
    9394   
    94         fprintf(stdout, "Solve Problem: %s\n", problemName);
     95        fprintf(stdout, "Solve Problem: %s (obj=%lg)\n", problemName, optimalValue);
    9596        hProb = CoinCreateProblem(problemName); 
    96         if (LoadNamesType > 0) {
    97                 result = CoinSetLoadNamesType(hProb, LoadNamesType);
    98         }
    9997        result = CoinLoadProblem(hProb, colCount, rowCount, nonZeroCount, rangeCount,
    10098                                        objectSense, objectConst, objectCoeffs, lowerBounds, upperBounds,
     
    109107        }
    110108        //result = CoinSetMsgLogCallback(hProb, &MsgLogCallback);
    111         if (!columnType)
     109        if (columnType == NULL)
    112110                result = CoinSetIterCallback(hProb, &IterCallback);
    113111        else {
     
    133131        char filename[260];
    134132   
    135         fprintf(stdout, "Solve Problem: %s\n", problemName);
     133        fprintf(stdout, "Solve Problem: %s (obj=%lg)\n", problemName, optimalValue);
    136134        hProb = CoinCreateProblem(problemName); 
    137135        result = CoinLoadProblemBuf(hProb, colCount, rowCount, nonZeroCount, rangeCount,
     
    147145        }
    148146        //result = CoinSetMsgLogCallback(hProb, &MsgLogCallback);
    149         if (!columnType)
     147        if (columnType == NULL)
    150148                result = CoinSetIterCallback(hProb, &IterCallback);
    151149        else {
     
    165163          double* lowerBounds, double* upperBounds, char* rowType, double* rhsValues, double* rangeValues,
    166164          int* matrixBegin, int* matrixCount, int* matrixIndex, double* matrixValues, char** colNames,
    167           char** rowNames, char* objectName, double* initValues, char* columnType, int LoadNamesType,
    168           int sosCount, int sosNZCount, int* sosType, int* sosPrior, int* sosBegin, int* sosIndex, double* sosRef)
     165          char** rowNames, char* objectName, double* initValues, char* columnType, int sosCount,
     166          int sosNZCount, int* sosType, int* sosPrior, int* sosBegin, int* sosIndex, double* sosRef)
    169167{
    170168        HPROB hProb;
     
    172170        char filename[260];
    173171   
    174         fprintf(stdout, "Solve Problem: %s\n", problemName);
    175         hProb = CoinCreateProblem(problemName); 
     172        fprintf(stdout, "Solve Problem: %s (obj=%lg)\n", problemName, optimalValue);
     173        hProb = CoinCreateProblem(problemName);
    176174        result = CoinLoadProblem(hProb, colCount, rowCount, nonZeroCount, rangeCount,
    177175                                        objectSense, objectConst, objectCoeffs, lowerBounds, upperBounds,
     
    187185        }
    188186        //result = CoinSetMsgLogCallback(hProb, &MsgLogCallback);
    189         if (!columnType)
     187        if ((columnType == NULL) && (sosCount == 0))
    190188                result = CoinSetIterCallback(hProb, &IterCallback);
    191189        else {
     
    226224        double objectCoeffs[8] = { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 };
    227225
    228         double lowerBounds[8] = { 0., 0., 0., 0., 0., 0., 0.  };
    229         double upperBounds[8] = { 1000000., 1000000., 1000000., 1000000., 1000000., 1000000., 1000000., 1000000.  };
     226        double lowerBounds[8] = { 0., 0., 0., 0., 0., 0., 0. };
     227        double upperBounds[8] = { 1000000., 1000000., 1000000., 1000000., 1000000., 1000000., 1000000., 1000000. };
    230228
    231229        char rowType[5] = { 'L', 'L', 'L', 'L', 'L' };
     
    251249          lowerBounds, upperBounds, rowType, rhsValues, NULL,
    252250          matrixBegin, matrixCount, matrixIndex, matrixValues,
    253           colNames, rowNames, objectName, initValues, NULL, 0);
     251          colNames, rowNames, objectName, initValues, NULL);
    254252}
    255253
     
    291289          lowerBounds, upperBounds, rowType, rhsValues, NULL,
    292290          matrixBegin, matrixCount, matrixIndex, matrixValues,
    293           colNames, rowNames, objectName, NULL, NULL, 0);
     291          colNames, rowNames, objectName, NULL, NULL);
    294292}
    295293
     
    365363        RunTestProblem(probname, optimalValue, ncol, nrow, nels, nrng,
    366364          objsens, objconst, dobj, dclo, dcup, rtyp, drhs, NULL, mbeg,
    367           mcnt, midx, mval, colnames, rownames, objectname, NULL, NULL, 0);
     365          mcnt, midx, mval, colnames, rownames, objectname, NULL, NULL);
    368366}
    369367
     
    442440        RunTestProblem(probname, optimalValue, ncol, nrow, nels, nrng,
    443441          objsens, objconst, dobj, dclo, dcup, rtyp, drhs, NULL, mbeg,
    444           mcnt, midx, mval, colnames, rownames, objectname, NULL, ctyp, 0);
     442          mcnt, midx, mval, colnames, rownames, objectname, NULL, ctyp);
    445443}
    446444
     
    485483        RunTestProblem(probname, optimalValue, ncol, nrow, nels, nrng,
    486484          objsens, objconst, dobj, dclo, dcup, rtyp, drhs, drng, mbeg,
    487           mcnt, midx, mval, colnames, rownames, objectname, NULL, ctyp, 0);
     485          mcnt, midx, mval, colnames, rownames, objectname, NULL, ctyp);
    488486}
    489487
     
    531529        RunSosTestProblem(probname, optimalValue, ncol, nrow, nels, nrng,
    532530          objsens, objconst, dobj, dclo, dcup, NULL, drlo, drup, mbeg,
    533           mcnt, midx, mval, colnames, rownames, objectname, NULL, NULL, 0,
     531          mcnt, midx, mval, colnames, rownames, objectname, NULL, NULL,
    534532          sosCount, sosNZCount, sosType, NULL, sosBegin, sosIndex, NULL);
    535533}
     
    576574        RunSosTestProblem(probname, optimalValue, ncol, nrow, nels, nrng,
    577575          objsens, objconst, dobj, dclo, dcup, rtyp, drhs, NULL, mbeg,
    578           mcnt, midx, mval, colnames, rownames, objectname, NULL, NULL, 0,
     576          mcnt, midx, mval, colnames, rownames, objectname, NULL, NULL,
    579577          sosCount, sosNZCount, sosType, NULL, sosBegin, sosIndex, NULL);
    580578}
    581 
    582579
    583580
     
    591588        SolverName = CoinGetSolverName();
    592589        CoinVersion = CoinGetVersion();
    593         fprintf(stdout, "UnitTest: %s version %lg\n\n",SolverName, CoinVersion);
     590        fprintf(stdout, "UnitTest: %s version %lg\n\n", SolverName, CoinVersion);
    594591        SolveProblemCoinTest();
    595592        SolveProblemBakery();
  • stable/1.4/CoinMP/test/unitTest.cpp

    r332 r333  
    6262        fprintf(stdout, "Solution Status: %d\n", solutionStatus);
    6363        fprintf(stdout, "Optimal Value:   %lg\n", objectValue);
    64         fprintf(stdout, "---------------------------------------\n");
    65      
     64        fprintf(stdout, "---------------------------------------\n");
     65
    6666        colCount = CoinGetColCount(hProb);
    6767        xValues = (double* )malloc(colCount * sizeof(double));
     
    224224        double objectCoeffs[8] = { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 };
    225225
    226         double lowerBounds[8] = { 0., 0., 0., 0., 0., 0., 0.  };
    227         double upperBounds[8] = { 1000000., 1000000., 1000000., 1000000., 1000000., 1000000., 1000000., 1000000.   };
     226        double lowerBounds[8] = { 0., 0., 0., 0., 0., 0., 0. };
     227        double upperBounds[8] = { 1000000., 1000000., 1000000., 1000000., 1000000., 1000000., 1000000., 1000000. };
    228228
    229229        char rowType[5] = { 'L', 'L', 'L', 'L', 'L' };
     
    266266        double objectCoeffs[2] = { 0.05 , 0.08 };
    267267
    268         double lowerBounds[2] = { 0, 0  };
    269         double upperBounds[2] = { 1000000, 1000000   };
    270    
     268        double lowerBounds[2] = { 0, 0 };
     269        double upperBounds[2] = { 1000000, 1000000 };
     270
    271271        char rowType[3] = { 'L', 'L' , 'L' };
    272272        double rhsValues[3] = { 1400 , 8000 , 5000 };
     
    401401
    402402        int midx[98]={0, 8, 9, 0, 12, 13, 0, 5, 6, 9, 0, 5, 6, 7, 1, 5, 6, 10, 11, 1,
    403                 5, 6, 8, 9, 1, 14, 2, 5, 6, 10, 11, 2, 5, 6, 8, 9, 3, 4, 3, 10, 11, 3, 5, 6,
     403                5, 6, 8, 9, 1, 14, 2, 5, 6, 10, 11, 2, 5, 6, 8, 9, 3, 4, 3, 10, 11, 3, 5, 6, 
    404404                11, 3, 5, 6, 9, 5, 6, 8, 9, 3, 4, 4, 12, 13, 12, 13, 13, 13, 5, 6, 10, 11, 5,
    405405                6, 10, 11, 5, 6, 11, 5, 6, 11, 5, 6, 8, 9, 5, 6, 8, 9, 5, 6, 9, 5, 6, 9, 5, 6,
     
    407407
    408408        double mval[98]={1, -300, -300, 1, -300, -300, 1, 300, -300, -300, 1, 300,
    409                 -300, -300, 1, 285, -285, -285, -285, 1, 285, -285, -285, -285, 1, -285, 1,
     409                -300, -300, 1, 285, -285, -285, -285, 1, 285, -285, -285, -285, 1, -285, 1, 
    410410                265, -265, -265, -265, 1, 265, -265, -265, -265, 1, -230, 1, -230, -230, 1,
    411411                230, -230, -230, 1, 230, -230, -230, 190, -190, -190, -190, 1, -200, -400,
    412                 -200, -200, -400, -400, -200, -400, 200, -200, -200, -200, 400, -400, -400,
     412                -200, -200, -400, -400, -200, -400, 200, -200, -200, -200, 400, -400, -400, 
    413413                -400, 200, -200, -200, 400, -400, -400, 200, -200, -200, -200, 400, -400,
    414414                -400, -400, 200, -200, -200, 400, -400, -400, 200, -200, -200, 400, -400,
Note: See TracChangeset for help on using the changeset viewer.