put results in a memory parameter

15 views
Skip to first unread message

Nozhan Hosseini

unread,
Apr 18, 2015, 8:40:32 AM4/18/15
to am...@googlegroups.com
Hello every one , i have a question

IN a loop i started getting results from my beginning part of codes

I want to collect these results to a vector or parameter or set and then compare these new parameters and do stuff

precisely i can say i want to put this sum in a vector or matrix


sum{i in ITEMS} VALUE[i] * choice[i]      :=       X

but i got error every time

in general how i can put a value coming from a loop to a matrix each time loop execute ?


victor.z...@gmail.com

unread,
Apr 18, 2015, 12:09:39 PM4/18/15
to am...@googlegroups.com
The result of the sum expression from your example is a scalar so you don't need a vector or a matrix. You can store it in a parameter using the let statement:

  param p;
  let p := sum{i in ITEMS} VALUE[i] * choice[i];

HTH,
Victor

--
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 ampl+uns...@googlegroups.com.
To post to this group, send email to am...@googlegroups.com.
Visit this group at http://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.

Nozhan Hosseini

unread,
Apr 18, 2015, 12:37:53 PM4/18/15
to am...@googlegroups.com
:(
syntax error

--
You received this message because you are subscribed to a topic in the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ampl/a3csUP9B-rU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ampl+uns...@googlegroups.com.

Robert Fourer

unread,
Apr 19, 2015, 8:32:30 PM4/19/15
to am...@googlegroups.com
To get some help with this error, you will need to post the complete error message. It will also help if you can post the AMPL definitions that you are currently using for ITEMS, VALUE, and choice.

Bob Fourer
am...@googlegroups.com

=======

From: am...@googlegroups.com [mailto:am...@googlegroups.com] On Behalf Of Nozhan Hosseini
Sent: Saturday, April 18, 2015 11:37 AM
To: am...@googlegroups.com
Subject: Re: [AMPL 10308] put results in a memory parameter

:(
syntax error

=======
Reply all
Reply to author
Forward
0 new messages