[AMPL 18342] Matrix of zeros

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

[AMPL 18342] Matrix of zeros

Priscila Rossoni
Hello dear all!

I'm having difficulty creating matrices in AMPL.
How to create an matrix of zeros and an matrix with fixed numbers?

param n := 20; 

param dim := 3; #Dimension

param sig := zeros(n,dim); #matrix of zeros "sig" with the dimension of the problem

param fitness := zeros(1,n); #vector of zeros assigning zero value for each n element

param gbest := (1 3 5); #global value of "best" initial value of the problem

param tap:= 1 2 3 
      3 4 5 
      5 6 7 ; #Matrix that defines the possible positions  (fix) 



--
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 18345] Matrix of zeros

AMPL mailing list
You could write

param sig {1..m,1..m,1..m} default 0;
param fitness {1..m} default 0;

and then later you could reassign some of these to nonzero values. Also in a model file you could write

param gbest {1..dim};
param tap {1..dim, 1..dim};

and then in your data file you could separately specify

param gbest := 1 1  2 3  3 5 ;
param tap: 1 2 3 :=
        1  1 2 3
        2  3 4 5
        3  5 6 7 ;


--
Robert Fourer
[hidden email]
{#HS:795359335-37915#}
On Wed, Mar 6, 2019 at 6:48 PM UTC, Ampl Modeling Language <[hidden email]> wrote:
Hello dear all!

I'm having difficulty creating matrices in AMPL.
How to create an matrix of zeros and an matrix with fixed numbers?

param n := 20;

param dim := 3; #Dimension

param sig := zeros(n,dim); #matrix of zeros "sig" with the dimension of the problem

param fitness := zeros(1,n); #vector of zeros assigning zero value for each n element

param gbest := (1 3 5); #global value of "best" initial value of the problem

param tap:= 1 2 3
3 4 5
5 6 7 ; #Matrix that defines the possible positions (fix)



--
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.