[AMPL 16170] unformatted data in .dat file

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[AMPL 16170] unformatted data in .dat file

Rupsana Parveen
Hi,
I have a parameter P1 as like below:

param route := 5;

param dest := 5;


param P1{i in 1.. route, j in 1.. dest};


I have a text file inputdata.txt which contains:

1 2 3 4 5

1 2 3 4 5

1 2 3 4 5

1 2 3 4 5

1 2 3 4 5


.run file:

read {i in 1.. route, j in dest }P1[i, j]<inputdata.txt;



But now I want to include that data for P1 into .dat file. I don't want to read text file in .run, instead I would like to add the data's of text file into .dat  directly. How to include the elements (5*5 matrix) of inputdata.txt file directly into .dat file?  


Thanks.

 

--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [AMPL 16171] unformatted data in .dat file

AMPL mailing list
You can specify your data in a tabular format as shown below:
param route := 5;
param dest := 5;
param P1{i in 1.. route, j in 1.. dest};
data;
param P1: 1 2 3 4 5:=
1 1 2 3 4 5
2 1 2 3 4 5
3 1 2 3 4 5
4 1 2 3 4 5
5 1 2 3 4 5;

Your data is trivial and could also be specified in model file as follows:

param route := 5;
param dest := 5;
param P1{i in 1.. route,j in 1..dest}:= j;

The first approach is the way to specify any data in two dimensional table. You can read about it https://ampl.com/BOOK/CHAPTERS/12-data.pdf (page 154).

Thanks,
Paras

--
Paras Tiwari
[hidden email]
{#HS:560295630-5111#}
On Fri, Apr 13, 2018 at 12:22 AM UTC, Zeyad Kassem' Via Ampl Modeling Language <[hidden email]> wrote:
Hi,
I have a parameter P1 as like below:

param route := 5;
param dest := 5;



param P1{i in 1.. route, j in 1.. dest};


I have a text file inputdata.txt which contains:

1 2 3 4 5


1 2 3 4 5


1 2 3 4 5


1 2 3 4 5


1 2 3 4 5




.run file:
read {i in 1.. route, j in dest }P1[i, j]<inputdata.txt;






But now I want to include that data for P1 into .dat file. I don't want to read text file in .run, instead I would like to add the data's of text file into .dat directly. How to include the elements (5*5 matrix) of inputdata.txt file directly into .dat file?




Thanks.

--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.



--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.