# Declaring just one variable as integer

**URL:** <https://discuss.ampl.com/t/declaring-just-one-variable-as-integer/1969>\
**Category:** Support\
**Created:** [November 1, 2024, 12:06pm UTC](https://discuss.ampl.com/t/declaring-just-one-variable-as-integer/1969 "2024-11-01T12:06:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yao](https://avatars.discourse-cdn.com/v4/letter/y/2bfe46/32.png) [@Yao](https://discuss.ampl.com/u/Yao)\
**Post date:** [November 1, 2024, 12:06pm UTC](https://discuss.ampl.com/t/declaring-just-one-variable-as-integer/1969/1 "2024-11-01T12:06:19Z")

</div>

Hi, I want to solve a problem with the Banch and Bound method with assistance of AMPL, however, when I want to declare just one variable as integer the program sends error.  
I have been using this .mod file:

```auto
param n; #Nº de variables de decisión 
param m; #Nº de restricciones

param c{i in 1..n}; #Vector de coeficientes función objetivo
param a{j in 1..m, i in 1..n}; # Matriz de coeficientes de las restricciones
param b{j in 1..m};# vector de lados derechos

var x{i in 1..n} >=0 ; #Variabes de decisión

maximize valor: sum{i in 1..n} c[i] * x[i]; #Función objetivo

subject to Restricciones{j in 1..m}: 
   sum{i in 1..n} a[j,i] * x[i] <= b[j]; #Restricciones

```

If someone could teach me how to declare, for example just `X[4]` as an integer with value `>=5` I would be extremely thankful.

That’s all. Good day.

---

<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:** [November 4, 2024, 3:57pm UTC](https://discuss.ampl.com/t/declaring-just-one-variable-as-integer/1969/2 "2024-11-04T15:57:55Z")

</div>

See [How do I relax the integrality of only some of a model’s integer variables?](https://discuss.ampl.com/t/how-do-i-relax-the-integrality-of-only-some-of-a-model-s-integer-variables/48) in our Frequently asked questions. Also, there is an example in a recent post about [Relaxing integrality on specific index values of a variable](https://discuss.ampl.com/t/relaxing-integrality-on-specific-index-values-of-a-variable/1959).

For your example, you could define

```auto
var x {i in 1..n} integer >= 0;

```

and then use these statements to say that `x[4]` must be an integer that is `>=5`:

```auto
let {i in 1..n} x[i].relax := (if i = 4 then 0 else 1);
subject to LowerBound: x[4] >= 5;

```
