Decision Optimization

 View Only
Expand all | Collapse all

Is there any way to write error & warning message in Opl into text file?

  • 1.  Is there any way to write error & warning message in Opl into text file?

    Posted Fri January 13, 2023 02:46 AM

    The question is as title asks.

    Is there any way to write error & warning message in Opl into text file?

    I need to store the information from "Problem Tab" in the Opl for each running case.

    Regards, Yen Ting



    ------------------------------
    Wu Jason
    ------------------------------

    #DecisionOptimization


  • 2.  RE: Is there any way to write error & warning message in Opl into text file?

    Posted Fri January 13, 2023 03:33 AM
    If I don't mistake, you will have to use the OPL api (C++, java or .NET) and will use the IloOplErrorHandler (see https://www.ibm.com/docs/en/icos/22.1.1?topic=c-ilooplerrorhandler or https://www.ibm.com/docs/en/icos/22.1.1?topic=classes-ilooplerrorhandler): The default implementation will write messages to cout or an alternate stream given to the constructor.

    You can look in the OPL examples, such as OplRunSample for a simple implementation of the equivalent of oplrun.


    ------------------------------
    Vincent Beraudier
    ------------------------------



  • 3.  RE: Is there any way to write error & warning message in Opl into text file?

    Posted Wed January 18, 2023 03:05 AM

    Hi, Vincent
    First of all thank you for your reply!
    Here is my C# code, I want to write the warning message to the "Log_WarningMessage.txt" file (Fig. 1), but it still write on the console (Fig. 2).
    Is there any wrong in my code?



    ------------------------------
    Wu Jason
    ------------------------------