Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
Expand all | Collapse all

Problem concatenating a string with variables

  • 1.  Problem concatenating a string with variables

    Posted 05/24/16 11:01 AM

    Originally posted by: hugotorres


    I want to concatenate the value of a variable to a string, but I'm failing to do so. I'm pretty sure that there's a way to do this but I can't find the example I was looking for.

    The idea is to read from an excel file dynamically, changing the number of the row. Right now my code on the .dat file is this one:

     

    myString = "A"+start+":K"+end
     
     SheetConnection mysheet("FiresReport_waste.xlsx");
     SheetConnection zonesSheet("zonesbin.xlsx");

     tableFires from SheetRead(mysheet,"TableFires");
     possibleZones from SheetRead(zonesSheet,myString);

     

    I get an error on the declaration of myString, saying "Unexpected character in "+", try using quoted string data, or check the encoding".

    Any suggestion on how to solve this?


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Problem concatenating a string with variables

    Posted 05/24/16 02:41 PM

    Hi,

    you cannot write

    myString = "A"+start+":K"+end

    in a .dat like that

    You should either write that in a .mod or use a prepare block

    see IDE and OPL > Optimization Programming Language (OPL) > Language Quick Reference > OPL keywords

    regards

    Alex Fleischer

    PS:

    Many how to with OPL at https://www.linkedin.com/pulse/how-opl-alex-fleischer/

    Many examples from a very good book : https://www.linkedin.com/pulse/model-building-oplcplex-alex-fleischer/

    Making optimization simple : https://www.linkedin.com/pulse/making-decision-optimization-simple-alex-fleischer/


    #DecisionOptimization
    #OPLusingCPLEXOptimizer