Fwd: [AIMMS] Re: Reading in text files

1,229 views
Skip to first unread message

Muminu Adamu

unread,
Dec 13, 2011, 11:01:13 AM12/13/11
to ai...@googlegroups.com

Good day,
 
I have read several parts of the documents and tried using the professional tutorial to program with my model without success. I intend reading in my text files for AIMMS to run. I was told to convert the data to excel or access files which I did but still find it difficult to link to my AIMMS program. I need an example I can conveniently follow. I have attached my data and AIMMS model for assistance. The columns representations are given below. Thanks
 
---------- Forwarded message ----------
From: Muminu Adamu <adam...@gmail.com>
Date: Fri, Nov 25, 2011 at 4:26 PM
Subject: Re: [AIMMS] Re: Using Maximum function
To: ai...@googlegroups.com


Good day,
 
I have been able to finish what I supposed to be done. I am having problem linking the data file with AIMMS. The example in the professional documentation is not very applicable to me. I have my data sets in text files with no labels on the first row.
 
the first column represents the EarliestDueDate in AIMMS  (Parameters)
the second column represents the LatestDueDate in AIMMS 
the third column represents the ProcessingTime in AIMMS
the fourth column represents the WeightOfJob in AIMMS
There are 20 folders with each containing 50 text files. I expect AIMMS to run all and give results for each. That is , there are 20 different situations and each with 50 samples to get the average performance.
 
You did indicate you could not see the project file and I hope this time around it would be attached. Please, I need to know the procedure to linking the files for subsequent usage. I have attached the aims files and data files. Hope to hear from you soon. Thanks
On Tue, Nov 22, 2011 at 4:18 AM, Mingliang Fang <mfl...@gmail.com> wrote:
Hi,

I was out of office last Friday for a week long vacation.

I took a quick look at the syntax error. The error "index k already has a scope" indicates in the definition of constraint, you already sum over k, but index domain is still defined over k. I adjusted the model simply based on the error. See the attached .aim file. Please double check to make sure the constraint is defined over indices correctly based on your formulation.     

BTW, I didn't see the problem formulation in your .rar file, but a binary .amb file. In order to open this file alone, I need to create a new project for it. If you share the model with other people, it is better to share both .prj and .amb files, or even .dat if you have save up some data cases. The attached .aim is a txt file which you can open the model with a text editor. Hope this helps! 

Thanks and happy holidays! 

On Mon, Nov 21, 2011 at 5:03 PM, Muminu Adamu <adam...@gmail.com> wrote:
Good day,

I sent a mail last Saturday and have not heard from you since then. Thanks for your anticipated response.

On Fri, Nov 18, 2011 at 8:03 PM, Mingliang Fang <mfl...@gmail.com> wrote:
Hi ,

The error message is complaining about the syntax. If you double click an error, it will take you to the location where the error occurs. 

Based on what you have in the message, it is not sure how you define the expressions and the constraint in the model. Would you mind to show a more complete code so that we can see the cause of the errors?

Thanks! 

Ming Fang   


On Fri, Nov 18, 2011 at 10:24 AM, Muminu Adamu <adam...@gmail.com> wrote:
Good day,
 
I tried your suggestion but I am still having some errors. This is what I did
 

CompletionMaximum(i) :=

max(k,CompletionTimeOnMachine(i,k-1))

EarliestStartTimeMax :=

max(j,EarliestStartTime)

sum

((j,k),(EarliestDuedate(j) - ProcessingTime(j))*PositionOnTimeOrTardy(i,j,k)) <= max(CompletionMaximum(i),EarliestStartTimeMax)
and the the following errors were displayed
 
The number of arguments in the variable "CompletionMaximum" is not correct.
The symbol ":=" is not expected.
 
Thanks for your prompt response.

On Thu, Nov 17, 2011 at 12:32 AM, Mingliang Fang <mfl...@gmail.com> wrote:
Hi,

It looks like the error message complains about the right hand side (RHS) of the constraint:

max((j,k),(CompletionTimeOnMachine(i,k-1),EarliestDuedate(j) - ProcessingTime(j)))

Max function in AIMMS can be used in the following two ways:

Max(binding domain, expression)
or 
Max(expression1, expression2, ...)

The formulation of RHS constraint combines them both. Thus, it is resulting the error of unexpected ",".

Maybe you can break down the RHS of constraint by defining two more expressions:

Exp1(i): max(k,CompletionTimeOnMachine(i,k-1))
Exp2: max(j,EarliestDuedate(j) - ProcessingTime(j))

then, RHS becomes:

max(Exp1(i), Exp2)

Based on your formulation, I assume the constraint has index domain i. 


Hope this helps! 

Ming Fang

 



On Wed, Nov 16, 2011 at 12:04 PM, Muminu Adamu <adam...@gmail.com> wrote:


On Nov 16, 5:26 pm, Muminu Adamu <adamu...@gmail.com> wrote:
> Good day,
>
> I need someone to assist me on how to represent the below constraint
> using the maximum function.
>
> aj   <=  {Max {Cik-1(S),aj – pj} + pj}xij       i=1,. . . ,m;  j =
> 1, . . . , n,
>
> i.e. finding the maximum of Cik-1 and aj-pj from k=1 . . j.

The AIMMS format used is given below

sum((j,k),(EarliestDuedate(j) -
ProcessingTime(j))*PositionOnTimeOrTardy(i,j,k)) <= max((j,k),
(CompletionTimeOnMachine(i,k-1),EarliestDuedate(j) -
ProcessingTime(j)))
It was given an error The symbol "," is not expected.
 It seems
> the function available in AIMMS cannot do this. Please, I need help.
> Thanks

--
You received this message because you are subscribed to the Google Groups "AIMMS - The Modeling System" group.
To post to this group, send email to ai...@googlegroups.com.
To unsubscribe from this group, send email to aimms+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/aimms?hl=en.


--
You received this message because you are subscribed to the Google Groups "AIMMS - The Modeling System" group.
To post to this group, send email to ai...@googlegroups.com.
To unsubscribe from this group, send email to aimms+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/aimms?hl=en.

--
You received this message because you are subscribed to the Google Groups "AIMMS - The Modeling System" group.
To post to this group, send email to ai...@googlegroups.com.
To unsubscribe from this group, send email to aimms+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/aimms?hl=en.

--
You received this message because you are subscribed to the Google Groups "AIMMS - The Modeling System" group.
To post to this group, send email to ai...@googlegroups.com.
To unsubscribe from this group, send email to aimms+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/aimms?hl=en.

--
You received this message because you are subscribed to the Google Groups "AIMMS - The Modeling System" group.
To post to this group, send email to ai...@googlegroups.com.
To unsubscribe from this group, send email to aimms+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/aimms?hl=en.

--
You received this message because you are subscribed to the Google Groups "AIMMS - The Modeling System" group.
To post to this group, send email to ai...@googlegroups.com.
To unsubscribe from this group, send email to aimms+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/aimms?hl=en.


Weighted Identical Parallel Machines.rar

Guido Diepen

unread,
Dec 13, 2011, 12:13:02 PM12/13/11
to ai...@googlegroups.com
Hi,

The easiest approach might be to do the following:

Create your text files again, but now with using the , as a value separator. Also use the extension .csv instead of .txt then. Instead of data0.txt, you will then create a file data0.csv that contains the following start:
   20,1374,92,3
   47,1394,84,6
   46,862,86,4

Now you can easily use the Excel functions within AIMMS to read the data from this CSV file.

For example, if you have a Set jobs with index j and the parameters EarliestDueDate and LatestDueDate, you can read the data with the Excel functions in AIMMS as follows:

ExcelRetrieveParameter( "data0.csv", EarliestDueDate , "A1:A160", "data0" ) ; 
ExcelRetrieveParameter( "data0.csv", LatestDueDate , "B1:B160", "data0" ) ; 

Please see the help of this particular function for more details about what the arguments mean. The other two columns can be read with similar statements, only different ranges. Keep in mind that the 160 is just one number I found in your files. Finally, to ensure the file is closed properly again, after reading the 4 columns, you can use the ExcelCloseWorkbook("data0.csv", 0) to close the file without saving it.

In your latest rar file, the project file is again missing. Please keep in mind that if you want to send your project to somebody else, you must make a ZIP file (or RAR) of the complete directory containing the .prj and .amb file. The only directories you can exclude are the log and backup subdirectory. 

Guido Diepen
AIMMS Specialist

Guido Diepen

unread,
Dec 13, 2011, 12:18:18 PM12/13/11
to ai...@googlegroups.com
Hi,

forgot to mention in my previous post, when reading in the data into the parameters with the ExcelRetrieveParameter function, you first must ensure that the set jobs (over which the parameters of the 4 columns are defined) contains 160 elements, namely one for each job for which you are going to read the data.

If your data file contains data for more or fewer jobs, also make sure that the set Jobs contains the right number of elements. 

Guido Diepen
AIMMS Specialist

Muminu Adamu

unread,
Dec 14, 2011, 12:39:05 PM12/14/11
to ai...@googlegroups.com
Thanks for the reply. I have again attached the correct files as demanded.
My problem is implementing what you wrote in AIMMS. AIMMS was not accepting my input similar to the professional example. I desire you try to enter it in my program for an example.
In addition, with this your method, would it not be too cumbersome when I am to run about 1000 similar data. Must I always change the data name for the earliest due date, latestduedate, etc. Thanks

--
You received this message because you are subscribed to the Google Groups "AIMMS - The Modeling System" group.
To view this discussion on the web visit https://groups.google.com/d/msg/aimms/-/of802rThVRkJ.
Weighted Identical Parallel Machines.rar

Guido Diepen

unread,
Dec 14, 2011, 2:15:58 PM12/14/11
to ai...@googlegroups.com
Hi,

what was the exact problem you had with implementing the approach mentioned in my previous post? In your project, i cannot find any reference to it.

I see that in your current project, you make use of dsn files and tables to access the files via a database. You might be able to access the txt files you have directly via the ODBC database layer, however, I think that you will have to provide more information to the ODBC Text driver to instruct it to use the space as a field separator...

The suggestion in my previous posts was to access the files via the ExcelRetrieveParameter function instead. One thing that is required for this however, is that you use some text editor to replace all the spaces in the .txt files with a comma (,). After you did this, you end up with CSV files, which can be opened directly in Excel (and thus also be read in via the ExcelRetrieveParameter function).

To read the data for one instance of your txt files, you will need 4 statements (i.e. the two statements I provided plus two similar ones for the other two columns). 

In a procedure, you can then loop over all the different input files, and for each of these input files, read that particular input file with 4 ExcelRetrieveParameter statements, solve the instance and write/save the result for that particular instance somewhere.

I hope this clarifies it a bit more. 

Guido Diepen
AIMMS Specialist

Muminu Adamu

unread,
Feb 3, 2012, 10:07:16 AM2/3/12
to ai...@googlegroups.com
Good day,
Well, its quite some weeks I got your last response. I was confused and had to rest, read more to know which way to go. I had gone through your several responses severally to understand you. Now, with my little understanding, I have devised an approach to follow but would still need your guidance to help since I am not very used to AIMMS.
 
I have converted all text files in one of my 20 data folders to Excel for you to expansiate the next thing to do. I have attach the data and others.
 
Now, the questions are
 
1. where/how do I create new declaration section for Database link section in my model ( ... in MainInitialization?)
2. where do I put the ExcelRetrievalParameter commands for the data in the model
3. How/where do I loop over the several data files for running
4. How do I read the data from my system into AIMMS (some confusions when the professional tutorial is considered)
Lastly, you can go through my model and suggest or assist where possible with these questions. Thanks and God bless.
 

Guido Diepen
AIMMS Specialist

--
You received this message because you are subscribed to the Google Groups "AIMMS - The Modeling System" group.
To view this discussion on the web visit https://groups.google.com/d/msg/aimms/-/3Vf9rzmy0h4J.
Weighted Identical Parallel Machines-2nd.rar

Guido Diepen

unread,
Feb 7, 2012, 8:42:24 AM2/7/12
to ai...@googlegroups.com
Hi,

the answers to your questions:
  1. You can create a new procedure for this. For example, you could create a procedure called ReadDataFromFile, which has a string parameter as an argument denoting the file from which the information should be read. Regarding MainInitialization, this is just one of the predefined procedures in AIMMS, which is executed before you first access any data after you started a project. My suggestion would be that you create a new procedure
  2. The ExcelRetrieveParameter statements should be in this new ReadDataFromFile procedure 
  3. You could create a new  procedure RunAllExperiments that contains a while loop. You could use the fact that your files follow a certain structure (i.e. name<number>.txt) by introducing a new parameter "myIterator". In the procedure you could then use some code like
    myIterator := 1 ; 
    while myIterator < 20 do
        ReadDataFromFile( "name" + myIterator + ".txt") ; 
        DoSolveModel ;   !this is some additional procedure that will contain the actual solve statement
        myIterator += 1 ; 
    endwhile ; 
  4. For reading the data from the Excel files, please forget about the tutorial for professionals at this moment. Using the ExcelRetrieveParameter will be a lot easier in this case for you. See the Excel Link example in our index of all examples for an example how to use this function.

Hope this helps a bit.

Guido Diepen
AIMMS Specialist
Reply all
Reply to author
Forward
0 new messages