Forum Discussion
FICO
3 years agoCommunity Manager
Another problem with the readln() function
Hello,
I have already posted a question on this topic (https://community.fico.com/s/question/0D54w0000CcOF2iCQG/a-problem-with-the-readln-function) without, unfortunately, getting any answer.
In the meantime, I have further investigated the problem and it turns out that, while a colleague of mine can correctly read an instance through a systematic call of the readline() function, in my computer things are different.
The script should read a .txt file and save the values into several variables and arrays.
However, a lot of them are not initialized at all.
I am attaching the main program (master_ufficiale.mos), the instance (istanza_di_prova.txt), the slave (slave_ufficiale.mos) and a screenshot with the problem encountered.
In the instance file, the program (master_ufficiale.mos) should read the number of bins and store it into variable Nt (line 43 of the script), the number of items and store it into variable Ni (line 44), the number of families and store it into variable Nf (line 45).
After that, there is a section concerning the bins.
The pieces of information concerning the bins should be saved into the arrays Wcat, Ccat, L, and U.
However, as proven in the scheenshot (forum.png), these arrays are empty and I don't know why.
Could anybody please help me?
Thank you very much and best regards,
Mauro Maria Baldi
2 Replies
- FICOCommunity Manager
Hello,
again, I cannot reproduce your problem here. When I put
writeln(Wcat)right after the loop that reads Wcat then I get this output:
[500,1000,2000]
So the data was read correctly.
Can you put the same statement, run your model and check the output?
When you say that things work correctly for your colleague, what is the difference between your machine colleague's? Are you using different operating systems? Different versions of Mosel? Did you use identical files?
- FICOCommunity Manager
I assume that the issue is the same as in the previous discussion: by (un)commenting 'readln' statements, the contents of the datafile no longer matches what the model is trying to read, and you are not reading information into the intended structures.
You might consider switching to work with Mosel's text data format (data files accessed through 'initializations from' blocks) then data entries are identified by labels, which would resolve the problem with skipping entries. - Notice however, that this would require some editing of the data file.
Related Content
Related Content
A problem with the readln function
Hello, I am having a problem with the readln() function. In fact, I want to read an instance file to start the optimization in a subsequent moment. In particular, I get the following error: Mosel:...3 years agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum3 unread comments3 unread0Views0likes3CommentsFICO Xpress Application migrating from one Windows VM to another
Hi, We are using FICO Xpress Optimization with Python to host Web Application, we are in process of migrating FICO application from one Server to another, due to some limitation we need to manually...2 years agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum3 unread comments3 unread0Views0likes3Comments