# \[AMPL 24563\] Constraint not being recognized by AMPL/KNitro

**URL:** <https://discuss.ampl.com/t/ampl-24563-constraint-not-being-recognized-by-ampl-knitro/411>\
**Category:** Google Group Mirror\
**Created:** [February 27, 2023, 4:39pm UTC](https://discuss.ampl.com/t/ampl-24563-constraint-not-being-recognized-by-ampl-knitro/411 "2023-02-27T16:39:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris\_Amaral](https://avatars.discourse-cdn.com/v4/letter/c/a88e57/32.png) [@Chris\_Amaral](https://discuss.ampl.com/u/Chris_Amaral)\
**Post date:** [February 27, 2023, 4:39pm UTC](https://discuss.ampl.com/t/ampl-24563-constraint-not-being-recognized-by-ampl-knitro/411/1 "2023-02-27T16:39:03Z")

</div>

Hello,

I am running into an issue when attempting to impose a constraint within my model. The constraint that I want to impose is that all values for a variable in a set are \>=0. Unfortunately, when I solve the model, I get results that do not account for this constraint (i.e., many values for the variable are negative). As you can see in the output below, AMPL/knitro is stating that there is no constraints in my model.

I have set my constraint up as follows:

subject to effort\_constraint {(t,o) in CHOICE\_SETS}: effort[t,o] \>=0;

where I have the following sets, variables, and data (for reserve):

set TIMES;

set OPTIONS;  
set CHOICE\_SETS within TIMES cross OPTIONS;  
var a0 \>= -3, \<= 3 default .1;

var a\_reserve \>= -3, \<= 3 default .1;  
var effort {(t,o) in CHOICE\_SETS} = a0 + a\_reserve \* reserve[t,o] ;

Below is the output from AMPL.

Substitution eliminates 1822104 variables.  
Adjusted problem:  
87 variables, all nonlinear  
0 constraints  
1 nonlinear objective; 87 nonzeros.

#presolve 0.016568 16777224 3103628912  
#output 1.50372 0 3103628912  
Artelys Knitro 12.4.0: outlev=6  
par\_numthreads=24

---

<div class="post-metadata">

**Author:** ![4er](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/4er/32/530_2.png) [@4er](https://discuss.ampl.com/u/4er)\
**Post date:** [March 3, 2023, 3:57am UTC](https://discuss.ampl.com/t/ampl-24563-constraint-not-being-recognized-by-ampl-knitro/411/2 "2023-03-03T03:57:15Z")

</div>

I tried out the AMPL statements that you show, with some made-up test data, but I did not observe the “0 constraints” that you are seeing. So, the error must be originating in some other part of your model and data. Some possibilities are that:

- CHOICE\_SETS is an empty set, due to some error in reading the data for it.
- Your constraint “effort\_constraint” is not being actually read by AMPL.

If you need more help, try replying with your complete model and data file uploaded. (Judging from the message “Substitution eliminates 1822104 variables,” your set “effort” may be very large; if so, it may be helpful to create a smaller data example for testing.)

---

<div class="post-metadata">

**Author:** ![AMPL\_Google\_Group](https://avatars.discourse-cdn.com/v4/letter/a/9dc877/32.png) [@AMPL\_Google\_Group](https://discuss.ampl.com/u/AMPL_Google_Group)\
**Post date:** [March 5, 2023, 8:57pm UTC](https://discuss.ampl.com/t/ampl-24563-constraint-not-being-recognized-by-ampl-knitro/411/3 "2023-03-05T20:57:22Z")

</div>

This question was cross-posted to our new user forum at [https://discuss.ampl.com](https://discuss.ampl.com), and an [answer has been posted](https://discuss.ampl.com/t/ampl-24563-constraint-not-being-recognized-by-ampl-knitro/411/2) there.
