-1

I'm new to developing code in AMPL. I started studying some tutorials and I'm trying to solve some exercises available on the internet.

I tried to develop a code for the problem shown at the end of this video link: https://www.youtube.com/watch?v=6XBoPbfsk_M

I’ve attached the .mod, .dat and .run files I wrote.

.mod file

.dat file

.run file

The error that I can´t solve right now is: “j is not defined” context: maximize profit: sum{j in J} Pj[j] * Xj[j] - sum{j in J} Kj[j] * DELTAj[j] + >>> Cj[j] <<< * Xj[j] ;

I would greatly appreciate it if anyone could help me with any other errors you may encounter.

Thiago
  • 9

1 Answers1

0

It looks like you have missing parenthesis in your objective fuction:

maximize profit: sum{j in J} Pj[j]*Xj[j] - Kj[j]*DELTAj[j] + Cj[j]*Xj[j];

You should add the parenthesis as follows:

maximize profit: sum{j in J} (Pj[j]*Xj[j] - Kj[j]*DELTAj[j] + Cj[j]*Xj[j]) ;

An index that appears in a sum operator is defined only until the next + or - sign that is outside of parentheses, or until the end of the statement.

fdabrandao
  • 81
  • 4