Forum Discussion

FICO's avatar
FICO
Community Manager
6 years ago

Can't find the reason for "E-113: Wrong type for conversion" error

Hi all,

Im new to Mosel so this may be an easy one. See example Mosel model below and find associated data file attached. When I run the code it seems Mosel is trying to convert one of the data types but I don't understand why? Any help greatly appreciated!

Will

model "Opt1 Question"
 uses "mmxprs" !"mmxnlp"
 
 
 declarations
 
  V1 = 1..269       ! Variable name
  OPT1 = array (V1) of mpvar               ! Optimum 
  COEFF1: array (V1) of real        ! Coefficients 
  
 end-declarations
 
 initializations from "Untitled1.dat"
    V1 COEFF1 
 end-initializations
 
 
!Objective function
 Titreobj := sum(t in V1) COEFF1(t)*OPT1(t) 
 
 maximize(linctr)(Titreobj)
 
 
 end

2 Replies

  • FICO's avatar
    FICO
    Community Manager

    The message is due to your declaration of OPT1 in line 8 of your code: by employing '=' you define a new type name in place of declaring an entity, please use ':' in place of '='. There are a few more points in the example that will go wrong: line 21 should simply be maximize(Titreobj) and the termination of a model code is indicated via 'end-model'. Furthermore, you need to define another name for the labels that you wish to read from the data file (or alternatively you could define 'V1' as a set of string). Resulting in the following:

    model "Opt1 Question"
     uses "mmxprs" !"mmxnlp"
     uses "mmsystem"
     
     declarations
      V1 = 1..269                       ! Variable indices
      OPT1 : array (V1) of mpvar        ! Decision variables 
      COEFF1: array (V1) of real        ! Coefficients  
      V1LABEL: array(V1) of text        ! Variable names
     end-declarations
     
     initializations from "Untitled1.dat"
        V1LABEL as "V1"   COEFF1 
     end-initializations
     
    !Objective function
     Titreobj := sum(t in V1) COEFF1(t)*OPT1(t) 
     setparam("XPRS_verbose",true)
     maximize(Titreobj)
     
    end-model
  • FICO's avatar
    FICO
    Community Manager

    Hi Susanne,

    That worked! Thanks for taking the time to formulate such a detailed answer.

    Will.

Related Content