Can't fix "syntax error"

Hi, I keep getting a syntax error on my code and I don’t know where I’m going wrong. Would appreciate any help.

I have 4 files so to be sure I’ll show them all.
Installation:

# Install and use AMPL with any solver on Colab
!pip install -q amplpy
from amplpy import tools
ampl = tools.ampl_notebook(
    modules=['cplex'],
    license_uuid="default")

Model.mod:

%%writefile model.mod

# Sets
set M;

# Parameters
param tw;
param tb;
param tm;
param tp;
param mpq{M};
param p{M};
param w{M};
param b{M};
param m{M};
param pl{M};

# Variables
var x{M} >= 0;
var y{M} binary;

# Objective
maximize profit : sum{m in M} p[m] * x[m];

# Constraints 1: Resource Limits Constraints
subject to wheels_constraint:
    sum{m in M} w[m] * x[m] <= tw;

subject to bolts_constraint:
    sum{m in M} b[m] * x[m] <= tb;

subject to metal_constraint:
    sum{m in M} m[m] * x[m] <= tm;

subject to plastic_constraint:
    sum{m in M} pl[m] * x[m] <= tp;


# Constraint 2: Minimal Production Constraints
subject to minimal_production_constraint{m in M}:
    mpq[m] * y[m] <= x[m] <= 100000 * y[m];

# Constraint 3: Binary Variable Constraints
subject to binary_variable_constraints{m in M}:
    0 <= y[m] <= 1;

# Constraints 4: Models Constraints
subject to models_constraint1:
    y[4] + y[5] + y[6] <= 2;

subject to models_constraint2:
    y[1] <= y[3];

subject to models_constraint3:
    y[7] + y[8] = 1;

Data.dat:

%%writefile data.dat

set M := 1..10;

param : p mpq :=
    1 10 200
    2 13 135
    3 27 270
    4 8 80
    5 14 45
    6 20 120
    7 42 420
    8 32 72
    9 60 460
    10 35 83;

param : w b m pl :=
    1 4 12 0 20
    2 4 0 0 13
    3 4 22 0 2
    4 5 8 2 8
    5 6 0 4 5
    6 0 12 1 2
    7 0 8 4 0
    8 0 4 7 0
    9 0 2 4 0
    10 0 10 8 0;

param tw := 100000;
param tb := 100000;
param tm := 90000;
param tp := 200000;

Running everything:

%%ampl_eval
reset;

option solver cplex;
option presolve 0;
option cplex_options 'presolve 0 sensitivity';

model model.mod;
data data.dat;

solve;

The problem specifically seems to happen inside Model.mod in the objective function. Everything looks correct to me but I may be missing something fairly obvious…

Solved. Apparently the variable m cannot be used in the sum since I defined a parameter named m. Thought that the inner m would shadow the outer m parameter but that’s not the case.

That’s right. After m is defined as a param, it cannot be used as an index in expressions like m in M.