Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

help with an error please!!

ALEX FLEISCHER

ALEX FLEISCHERMon May 06, 2019 05:49 AM

Archive User

Archive UserMon May 06, 2019 06:59 AM

  • 1.  help with an error please!!

    Posted Sat April 27, 2019 12:13 PM

    Originally posted by: wj1


    please find attached my .mod ,.dar files and the excel file ... for the constraint 10 i got an error , the size of the range is not the size of the array.

     

    pLease help !!


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: help with an error please!!

    Posted Mon May 06, 2019 05:49 AM

    Hi,

    if you do

    execute
    {
    writeln("nb courses =",course.size);
    writeln("nb faculties = ",faculties.size);
    }

    you get

    nb courses =62
    nb faculties = 76

    Is your named range "nb_section_faculty_course" the same size ? I do not think so

     

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: help with an error please!!

    Posted Mon May 06, 2019 06:59 AM

    Originally posted by: wj1


    Hi Alex ,

     

    how can i fix it , i've been trying for days now ... i only have 62 courses and 76 faculties ..im trying to read the column from excel

     

    please help, thank youuuuu!


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: help with an error please!!

    Posted Tue May 07, 2019 12:27 PM

    Instead of using a named range, why do not you try to use SheetRead with a range ?

    See

    https://www.ibm.com/developerworks/community/forums/html/topic?id=c2469c56-db27-4816-9cf2-f596513ce555&ps=25

    on how to transform R1C1 ranges into the ones SheetRead accepts

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: help with an error please!!

    Posted Tue May 07, 2019 12:31 PM

    Originally posted by: wj1


    the thing is im a very beginnner on opl ... is there any easier method ?


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: help with an error please!!

    Posted Tue May 07, 2019 12:41 PM


  • 7.  Re: help with an error please!!

    Posted Tue May 07, 2019 12:42 PM

    Originally posted by: wj1


    ok im gonna check it out , i hope i can fix it ...  it's my last error ..thank you


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 8.  Re: help with an error please!!

    Posted Tue May 07, 2019 01:06 PM

    Ok can you tell me where is that matrix of 62*76 ?

    In which tab ? And what is are the extreme cells ?

    regards

     

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 9.  Re: help with an error please!!

    Posted Tue May 07, 2019 01:10 PM

    Originally posted by: wj1


    ok, so , it's about constraint number 10 which is :

    forall(<i,f> in Course_To_Faculty)sum( j in section :<i,j>in Course_To_Section) z[f][j]==nb_section_faculty_course[i][f];

     

    so nb_section_faculty_course , you could find in the excel file .. you could type the name the name and you will see the range ...

    thank you sooo much alex , i appreciate iiittt !!!


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 10.  Re: help with an error please!!

    Posted Tue May 07, 2019 01:33 PM

    Hi

    I see a column with 193 values.

    Whereas OPL is expecting

    nb courses =62
    nb faculties = 76

    So you need to fix that

    regards

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 11.  Re: help with an error please!!

    Posted Tue May 07, 2019 01:35 PM

    Originally posted by: wj1


    that's the thing i couldn't figure out because the excel file is a data i got from the university ... i feel like i don't know what to do ...could u help me fix it ?


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 12.  Re: help with an error please!!

    Posted Tue May 07, 2019 01:57 PM

    then waiting for you customer data you could try

    float nb_section_faculty_course[c in course][f in faculties]=10;

    in order to use fake values in the meantime

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 13.  Re: help with an error please!!

    Posted Tue May 07, 2019 01:59 PM

    Originally posted by: wj1


    ok i will try a fake value... do u know someone who could help me asap , i need to hand in the model this week...thank you 


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 14.  Re: help with an error please!!

    Posted Tue May 07, 2019 04:10 PM

    Hi

    or insteadf of fake values you could try

    .mod

    int temp[1..105]=...;
    float nb_section_faculty_course[c in course][f in faculties]=temp[f];

    and in .dat

    temp from SheetRead (my_sheet,"nb_section_faculty_course");

    At least this show how to get the values out of the named range.

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 15.  Re: help with an error please!!

    Posted Wed May 08, 2019 01:06 PM

    Originally posted by: wj1


    i ahve done this alex and it worked :

    forall (s in Course_To_Faculties) 
      sum(t in Course_To_Section: s.i == t.i)z[s.f][t.j] == s.groupsize;

     

    someone helped write the last command about exporting the decision variable x but i tried to export y ,z and aplha and got many errors ...could u help with the command that will export y,z and alpha ? thannk youuuu !!


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 16.  Re: help with an error please!!

    Posted Thu May 09, 2019 03:39 AM

    Hi

    you should use SheetWrite

    You may find an example in CPLEX_Studio129\opl\examples\opl\oil

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 17.  Re: help with an error please!!

    Posted Fri May 10, 2019 11:08 AM

    Originally posted by: wj1


    Hey alex , i did that but i got the error in the screenshot attached ... any help ? thank you and god bless you!


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 18.  Re: help with an error please!!



  • 19.  Re: help with an error please!!

    Posted Fri May 10, 2019 01:00 PM

    Originally posted by: wj1


    im sorry alex for botherring , wras i told u , im a begiiner in opl ... i found what u wrote not much understandable for me...could you help with one exmple? for instance , i want to export y(s,j) : s in student and j in section ...thaank youuuuu


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 20.  Re: help with an error please!!

    Posted Fri May 10, 2019 04:05 PM

    Hi,

    if you adapt the example I shared, you will write

    execute
        {

        // http://cwestblog.com/2013/09/05/javascript-snippet-convert-number-to-column-name/
        function toColumnName(num) {
          for (var ret = '', a = 1, b = 26; (num -= a) >= 0; a = b, b *= 26) {
            ret = String.fromCharCode(parseInt((num % b) / a) + 65) + ret;
          }
          return ret;
        }

        // 1,1 => A1  1,4 => D1 2,27 => AA2
        function convertR1C1toA1(r,c)
        {
        return(toColumnName(c)+r);
        }

        }
        
    string sheeetWriteString;

    execute
    {
    sheeetWriteString="test!A1:"+convertR1C1toA1(student.size,section.size);  
    }  

    and that will write y in the tab "test"

    At some point do not hesitate to follow some training : https://www.linkedin.com/pulse/low-barrier-entry-optimization-through-cplex-alex-fleischer/

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer