Search code examples
syntax-errorampl

Is there a way to decode the syntax error, to find out where it is referring to?


I'm making a MIP, which I'm trying to run trough NEOS cplex (AMPL). Every time I run it, I get the same error code, even though I have tried to find and fix the error The error I get is: "amplin, line 9 (offset 93): syntax error context: >>> {\ <<< rtf1\ansi\ansicpg1252\cocoartf1671"

I'm fairly new to AMPL, so therefore I'm a bit unsure, what the error code means. My code is split in a model file, and a data file, both written as a .txt file. I can't seem to locate the error. Model:

# Parameters
    param m;
    param n;
    param T;
    param sigma{t in 1..T};
    param capacity{j in 1..m};
    param demand{i in 1..n};
    param cost{i in 1..n, j in 1..m};
    param holding;
    param InInv{j in 1..m};


# Decision variables
    var x{i in 1..n, j in 1..m} binary;
    var Produced{j in 1..m, t in 1..T} integer <= capacity[j] >= 0;
    var sold{j in 1..m, t in 1..T} integer >= 0;
    var inventory{j in 1..m, t in 0..T} integer >= 0;

# Objective function
    minimize TotalCost: sum{i in 1..n, j in 1..m} x[i,j]*cost[i,j] + sum{j in 1..m, t in 1..T}holding * inventory[j,t];

# Constraints
    subject to BalanceInventory {j in 1..m, t in 1..T}:
        Produced[j,t]+inventory[j,t-1]=sold[j,t]+inventory[j,t];

    subject to SingleSourcing {i in 1..n}:
        sum{j in 1..m} x[i,j] = 1;

    subject to InitInv {j in 1..m}:
        inventory[j,0]=InInv[j];

Data:

#Parameters
param m := 4;

param n := 30;

param T := 6;

param sigma := 1 0.125 2 0.125 3 0.25 4 0.125 5 0.125 6 0.25;

param capacity := 1 375  2 375  3 375  4 375;

param demand := 1 200 2 492 3 91 4 190 5 351 6 323 7 23 8 157 9 374 10 351 11 432 12 161 13 300 14 300 15 219 16 339 17 312 18 653 19 440 20 207 21 281 22 233 23 409 24 215 25 7 26 680 27 215 28 395 29 165 30 333;

param cost :
1 2 3 4 :=
1 6.97 3.47 1.73 4.34
2 9.67 3.05 2.78 6.89
3 4.01 4.33 7.2 8.67
4 3.97 5.33 4.75 4.47
5 5.91 5.98 3.6 2.42
6 9.49 6.14 1.67 3.28
7 6.03 3.60 7.53 9.83
8 6.12 6.13 3.57 2.17
9 2.48 7.22 6.9 5.66
10 8.41 3.41 1.11 5.07
11 2.34 5.47 6.32 8.08
12 6.97 5.22 2.15 2.59
13 4.51 3.43 6.32 8.08
14 8.63 8.46 4.63 0.69
15 3.57 4.06 6.01 7.18
16 8.05 4.06 8.48 11.35
17 10.36 5.38 1.77 5.19
18 0.89 8.38 9.5 8.87
19 7.04 1.11 5.39 8.4
20 0.99 6.88 8.33 8.28
21 0.59 7.22 8.49 8.24
22 7 1.34 3.36 6.48
23 2.88 5.28 7.59 8.5
24 8.32 0.73 4.4 8.01
25 6.85 1.41 3.4 6.43
26 4.09 7.19 5.88 4.06
27 8.48 1.38 3.5 7.26
28 1.02 8.47 9.05 8.03
29 6.14 2.39 6.3 8.83
30 9.07 6.23 1.83 2.7;

param holding := 1;

param InInv := 1 0 2 0 3 0 4 0;

So if anyone can help me guide me towards the error, so I can fix it, I would really appreciate it.

Sincerely a desperate new-coder.


Solution

  • You could try installing the size-limited demonstration version of AMPL, reducing the problem size as necessary to fit within the limits of that version, and using that to test your code.

    This will help identify whether the problem is in your syntax, or something related to how you're using NEOS. As suggested by @melpomene it's also possible that the file you're sending is not in the expected format, so try passing it through a plain text editor e.g. the AMPL IDE's editor.

    In my experience, debugging NEOS runs can be frustrating, so best to do as much of the debugging as possible on a local system where you can get a bit more feedback.