Knapsack problem with incompatibility, Help with AMPL

341 Views Asked by At

I have a fairly straight forward problem. I have to like solve the knapsack problem with incompatibility.

The way I have set the problem up is:

Problem setup

Meaning that item i and j can not be included at the same time.

This is the mod.file enter image description here

When I upload it to Neos I get this error message.

amplin, line 30 (offset 306): syntax error context: >>> var <<< x{i in 1..n} binary;

I don't quite understand why it does not read x as a variable.

Thanks

Edit: I would like someone to help me understand why I get the error message when I upload my AMPL file to Neos.

1

There are 1 best solutions below

17
On BEST ANSWER

You are missing a terminating semicolon for the previous "param" statement.

Also, your incomp constraint has a superfluous sum operator.

By the way, incompatibility like this is usually modeled with a "conflict" constraint $x_i + x_j \le 1$ for each bad pair $i<j$.