Changeset 351


Ignore:
Timestamp:
Nov 12, 2009 12:52:12 PM (10 years ago)
Author:
bjarni
Message:

Add SolveProblemSemiConst? to test semi-continous variables and add SemiCont/Priority? handling to RunTestProblemMip?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/CoinMP/test/unitTest.cpp

    r334 r351  
    159159
    160160
    161 void RunSosTestProblem(char* problemName, double optimalValue, int colCount, int rowCount,
     161void RunTestProblemMip(char* problemName, double optimalValue, int colCount, int rowCount,
    162162          int nonZeroCount, int rangeCount, int objectSense, double objectConst, double* objectCoeffs,
    163163          double* lowerBounds, double* upperBounds, char* rowType, double* rhsValues, double* rangeValues,
    164164          int* matrixBegin, int* matrixCount, int* matrixIndex, double* matrixValues, char** colNames,
    165165          char** rowNames, char* objectName, double* initValues, char* columnType, int sosCount,
    166           int sosNZCount, int* sosType, int* sosPrior, int* sosBegin, int* sosIndex, double* sosRef)
     166          int sosNZCount, int* sosType, int* sosPrior, int* sosBegin, int* sosIndex, double* sosRef,
     167          int semiCount, int* semiIndex, int priorCount, int* priorIndex, int* priorValues, int* priorBranch)
    167168{
    168169        HPROB hProb;
     
    179180                result = CoinLoadInteger(hProb, columnType);
    180181        }
    181         result = CoinLoadSos(hProb, sosCount, sosNZCount, sosType, sosPrior, sosBegin, sosIndex, sosRef);
     182        if (priorCount > 0) {
     183                result = CoinLoadPriority(hProb, priorCount, priorIndex, priorValues, priorBranch);
     184        }
     185        if (sosCount > 0) {
     186                result = CoinLoadSos(hProb, sosCount, sosNZCount, sosType, sosPrior, sosBegin, sosIndex, sosRef);
     187        }
     188        if (semiCount > 0) {
     189                result = CoinLoadSemiCont(hProb, semiCount, semiIndex);
     190        }
    182191        result = CoinCheckProblem(hProb);
    183192        if (result != SOLV_CALL_SUCCESS) {
     
    185194        }
    186195        //result = CoinSetMsgLogCallback(hProb, &MsgLogCallback);
    187         if ((columnType == NULL) && (sosCount == 0))
     196        if ((columnType == NULL) && (sosCount == 0) && (semiCount == 0))
    188197                result = CoinSetIterCallback(hProb, &IterCallback);
    189198        else {
     
    527536        double optimalValue = 0.72;
    528537
    529         RunSosTestProblem(probname, optimalValue, ncol, nrow, nels, nrng,
     538        RunTestProblemMip(probname, optimalValue, ncol, nrow, nels, nrng,
    530539          objsens, objconst, dobj, dclo, dcup, NULL, drlo, drup, mbeg,
    531540          mcnt, midx, mval, colnames, rownames, objectname, NULL, NULL,
    532           sosCount, sosNZCount, sosType, NULL, sosBegin, sosIndex, NULL);
     541          sosCount, sosNZCount, sosType, NULL, sosBegin, sosIndex, NULL,
     542          0, NULL, 0, NULL, NULL, NULL);
    533543}
    534544
     
    572582        double optimalValue = 0.0;
    573583
    574         RunSosTestProblem(probname, optimalValue, ncol, nrow, nels, nrng,
     584        RunTestProblemMip(probname, optimalValue, ncol, nrow, nels, nrng,
    575585          objsens, objconst, dobj, dclo, dcup, rtyp, drhs, NULL, mbeg,
    576586          mcnt, midx, mval, colnames, rownames, objectname, NULL, NULL,
    577           sosCount, sosNZCount, sosType, NULL, sosBegin, sosIndex, NULL);
    578 }
    579 
     587          sosCount, sosNZCount, sosType, NULL, sosBegin, sosIndex, NULL,
     588          0, NULL, 0, NULL, NULL, NULL);
     589}
     590
     591
     592void SolveProblemSemiCont(void)
     593{
     594        char* probname = "SemiCont";
     595        int ncol = 4;
     596        int nrow = 3;
     597        int nels = 6;
     598        int nrng = 0;
     599       
     600        char* objectname = "z";
     601        int objsens = SOLV_OBJSENS_MIN;
     602        double objconst = 0.0;
     603        double dobj[7]={0.0, 1.0, 1.0, 0.0};
     604
     605        double dclo[7]={2.8, 0.0, 0.0, 0.0};
     606        double dcup[7]={10.0, 1e+37, 1e+37, 1e+37};
     607
     608        char rtyp[5]= {'L', 'G', 'E'};
     609        double drhs[5]={8.9, 8.9, 10.0};
     610
     611        int mbeg[4+1]={0, 1, 2, 3, 6};
     612        int mcnt[4]={1, 1, 1, 3};
     613        int midx[6]={2, 0, 1, 0, 1, 2};
     614        double mval[15]={1, -1, 1, 1, 1, 1};
     615
     616        char* colnames[7] = {"s", "pup", "plo", "x"};
     617        char* rownames[5] = {"bigx", "smallx", "f"};
     618
     619        //char* colnamesBuf = "s\0" "pup\0" "plo\0" "x\0";
     620        //char* rownamesBuf = "bigx\0" "smallx\0" "f\0";
     621
     622        int semiCount = 1;
     623        int semiIndex[1] = {0};
     624
     625        double optimalValue = 1.1;
     626
     627        RunTestProblemMip(probname, optimalValue, ncol, nrow, nels, nrng,
     628          objsens, objconst, dobj, dclo, dcup, rtyp, drhs, NULL, mbeg,
     629          mcnt, midx, mval, colnames, rownames, objectname, NULL, NULL,
     630          0, 0, NULL, NULL, NULL, NULL, NULL, semiCount, semiIndex,
     631          0, NULL, NULL, NULL);
     632}
    580633
    581634
     
    596649        SolveProblemGamsSos1a();
    597650        SolveProblemGamsSos2a();
     651        SolveProblemSemiCont();
    598652        fprintf(stdout, "All unit tests completed successfully\n" );
    599653        CoinFreeSolver();
Note: See TracChangeset for help on using the changeset viewer.