Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.

 View Only
  • 1.  Expecting algorithm CPLEX, found CP

    Posted Tue May 06, 2008 05:35 PM

    Originally posted by: SystemAdmin


    [shadi said:]


    Im trying to execute my Slave Model which uses Constraints Programming, using the following code (cutstock example):





            Dim oplF As OplFactory = New OplFactory

            OplFactory.DebugMode = True



            Dim masterCplex As Cplex = oplF.CreateCplex()

            masterCplex.SetOut(Nothing)



            Dim errorHandler As OplErrorHandler = oplF.CreateOplErrorHandler()

            Dim masterRC As OplRunConfiguration = oplF.CreateOplRunConfiguration(applicationPath &  "\OPLFiles\MyModel.mod", applicationPath & "\OPLFiles\Mydata.dat")



            masterRC.ErrorHandler = errorHandler

            masterRC.Cplex = masterCplex

            Dim masterOpl As OplModel = masterRC.OplModel

            masterOpl.generate()

            Dim masterDataElements As OplDataElements = masterOpl.MakeDataElements()





    But I got the following error:

    Expecting algorithm CPLEX, found CP

    how i can solve this problem???




    #DecisionOptimization
    #OPLusingCPOptimizer


  • 2.  Re: Expecting algorithm CPLEX, found CP

    Posted Tue May 06, 2008 06:53 PM

    Originally posted by: SystemAdmin


    [Didier Vidal said:]

    shadi,

    Does your model start with 'using CP' ?

    In this case, you should create your model with a CP engine instead of a CPLEX engine,
    Below is code sniplet in Java (sorry, that's all I have right now), but that should show you hos to change your code although there are minor differences between the Java and VB.net APIs


    IloCP cp = oplF.createCP();
    masterRC.setCP(cp);


    Didier.
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 3.  Re: Expecting algorithm CPLEX, found CP

    Posted Wed May 07, 2008 11:23 AM

    Originally posted by: SystemAdmin


    [shadi said:]

    Didier, first of all thank you very much....

    yes my model start with 'using CP' so i tried the following code

    [b]        Dim oplF As OplFactory = New OplFactory
            OplFactory.DebugMode = True
            Dim masterCp As CP = oplF.CreateCP
            masterCp.SetOut(Nothing)
            Dim errorHandler As OplErrorHandler = oplF.CreateOplErrorHandler()
            Dim masterRC As OplRunConfiguration = oplF.CreateOplRunConfiguration(applicationPath & "\OPLFiles\MyModel.mod", applicationPath & "\OPLFiles\MyData.dat")
            masterRC.ErrorHandler = errorHandler
            [font=Verdana]masterRC.setCP(masterCp)[/font]
            Dim masterOpl As OplModel = masterRC.OplModel
            masterOpl.generate()
    [/b]

    but i got the following error
    [i]Value of type 'ILOG.CP.CP' cannot be converted to 'ILOG.CP.Cppimpl.IloCP'.[/i]


    Shadi

    #DecisionOptimization
    #OPLusingCPOptimizer


  • 4.  Re: Expecting algorithm CPLEX, found CP

    Posted Wed May 07, 2008 05:19 PM

    Originally posted by: SystemAdmin


    [Didier Vidal said:]

    Shadi,

    I see the same problem.
    A workaround is to build your model directly from the mod file and the dat file, insteas of using a run configuration.

    Below is some code that compiles for me - You also have a full example of the .net API for OPL and CP at OPL55\examples\dotnet\x86_.net2003_7.1\Warehousecp



    Imports ILOG.OPL
    Imports ILOG.Concert
    Imports ILOG.CP


    Module Module1

        Sub Main()
            Dim oplF As OplFactory = New OplFactory
            OplFactory.DebugMode = True
            Dim modelSource As OplModelSource = oplF.CreateOplModelSource("\OPLFiles\MyModel.mod")
            Dim errorHandler As OplErrorHandler = oplF.CreateOplErrorHandler()
            Dim settings As OplSettings = oplF.CreateOplSettings(errorHandler)
            Dim def As OplModelDefinition = oplF.CreateOplModelDefinition(modelSource, settings)

            Dim masterCp As CP = oplF.CreateCP

            Dim model As OplModel = oplF.CreateOplModel(def, masterCp)

            Dim data As OplDataSource = oplF.CreateOplDataSource("\OPLFiles\MyModel.dat")
            model.AddDataSource(data)
            model.generate()

        End Sub

    End Module

    #DecisionOptimization
    #OPLusingCPOptimizer


  • 5.  Re: Expecting algorithm CPLEX, found CP

    Posted Wed May 07, 2008 05:32 PM

    Originally posted by: SystemAdmin


    [shadi said:]

    Dear Didier Vidal,

    i build  model directly from the mod file and the dat file, without using a run configuration.

    my problem is how  can i change some veriables values from the datasource and to run again my opl model with the new values


    my code seem like this


            Dim counter As Integer
            For counter = 1 To 50
                Dim oplF As OplFactory = New OplFactory
                Dim errHandler As OplErrorHandler = oplF.CreateOplErrorHandler(Console.Out)
                OplFactory.DebugMode = True
                Dim masterCp As CP = oplF.CreateCP

                Dim Modelsource As OplModelSource = oplF.CreateOplModelSource(applicationPath & "\OPLFiles\MyModel.mod")
                Dim datasource As OplDataSource = oplF.CreateOplDataSource(applicationPath & "\OPLFiles\MyData.dat")
                Dim setting1 As OplSettings = oplF.CreateOplSettings(errHandler)
                Dim def As OplModelDefinition = oplF.CreateOplModelDefinition(Modelsource, setting1)
                Dim opl As OplModel = oplF.CreateOplModel(def, masterCp)
                opl.AddDataSource(datasource)



                Dim CpDataElements As OplDataElements = opl.MakeDataElements
                CpDataElements.setElement(CpDataElements.MakeElement("coverTrip", counter))
                opl.AddDataSource(CpDataElements)
                opl.Generate()

                'MsgBox(CpDataElements.GetElement("coverTrip").AsInt)
                'MsgBox(opl.GetElement("coverTrip").AsInt)

                If masterCp.Solve Then
                    opl.printSolution(Console.Out)
                End If


                oplF.End()

            Next



    each time time i want to change the value of the integer veriable (coverTrip) and to run again my model
    Thank you
    Kshieboun Shadi



    #DecisionOptimization
    #OPLusingCPOptimizer


  • 6.  Re: Expecting algorithm CPLEX, found CP

    Posted Wed May 07, 2008 06:01 PM

    Originally posted by: SystemAdmin


    [Didier Vidal said:]

    If you want to create the data from code source, then you should use what is called a 'CustomDataSource'

    The example warehousecp, that I discussed earlier, uses this class. You may have a look at it to see how this works. It is written in C#.
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 7.  Re: Expecting algorithm CPLEX, found CP

    Posted Wed May 07, 2008 06:15 PM

    Originally posted by: SystemAdmin


    [alain.chabrier said:]

    Hi,

    the issue on
    masterRC.setCP(masterCp)
    was found before and is now registered as OPL-3516.
    It is fixed in the coming OPL60.

    Value of type 'ILOG.CP.CP' cannot be converted to 'ILOG.CP.Cppimpl.IloCP'.

    Another workaround is to use :
    masterRC.setCP(masterCp.GetCPImpl());

    Thanks,

    Alain
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 8.  Re: Expecting algorithm CPLEX, found CP

    Posted Wed May 07, 2008 06:37 PM

    Originally posted by: SystemAdmin


    [shadi said:]

    Didier Vidal,
    my Data file has more complex data type than integer as in the example
    my data file is:


    /*********************************************
    * OPL 5.5 Data
    * Author: Hugues Juille
    * Creation Date: 12/6/2007 at 4:02 PM
    *********************************************/

    LocationType={<", 1>, <", 0>, <", 0>, <", 0>};

    TypeOfTrip = {"inter city", "city", "regional"};

    TypeOfService = {"school trip", "regular trip", "service trip"};

    SheetConnection sheet("TLV-NTN Bus TimeTables & Costs.xls");
    // RawTimetable from SheetRead(sheet,"SUN!R3:X485");
    // Segments from SheetRead(sheet,"SUN!AA3:AE485");

    RawTimetable from SheetRead(sheet,"SUN!R3:X79");
    Segments from SheetRead(sheet,"SUN!AA3:AE79");

    //RawTimetable from SheetRead(sheet,"SUN!R3:X28");
    //Segments from SheetRead(sheet,"SUN!AA3:AE28");

    //RawTimetable from SheetRead(sheet,"SUN!R3:X12");
    //Segments from SheetRead(sheet,"SUN!AA3:AE12");

    Timetable={};

    CostStructureType = {"CityBus_55passenger_CST", "InterCity_55passenger_CST", "LowEntryBus_55passenger_CST"};
    BusCategories = {
                <", "city", "CityBus_55passenger_CST", 55, 0>,
                <", "inter city", "InterCity_55passenger_CST", 55, 0>,
                <", "inter city", "InterCity_55passenger_CST", 55, 1>
                };
    Fleet = {
            <", 5, 7>,
            <", 5, 7>,
            <", 2, 11>,
            <", 4, 6>
            };

    coverTrip=5;
    busCategoryId = "InterCity_55passengerManual";

    nSeq    = 20;
    minStop = 2;
    maxStop = 50;
    longStop = 240;

    Origin = [];
    Destination = [];
    OriginLoc = [];
    DestinationLoc = [];
    DepTime = [];
    ArrTime = [];
    StartFromDepot = [];
    Distance = [];
    isEmptyTrip = [];
    tripType = [];

    busCategoryIdx = [];
    busTypeByCategory = [];


    which as you can see has tuples, tupleset, ranges....
    so can i use this method in order to assign all these data types?????

    thank you




    #DecisionOptimization
    #OPLusingCPOptimizer


  • 9.  Re: Expecting algorithm CPLEX, found CP

    Posted Wed May 07, 2008 06:55 PM

    Originally posted by: SystemAdmin


    [alain.chabrier said:]

    Hi,

    as Didier suggestm you may have a look at the example in :
    OPL55\examples\dotnet\x86_.net2005_8.0\Warehousecp

    It uses a sub class of CustomOplDataSource.
    This is a thrid way of creating data source (apart from .dat files and OplDataElements).
    This one is more appropriate when you want to fill in data from a programming language, and when the data is mutliple, and include more complex structures.

    Alain

    #DecisionOptimization
    #OPLusingCPOptimizer