# Logical constraint in ILP

Operations Research Asked by che on December 22, 2020

I want to write the following constraint:

Let $$z$$ be an integer variable such that $$0le zle M$$, and $$t$$ be a binary variable where $$M$$ denotes big-M. The logical constraint is as follows:

• if $$z leq M$$ and $$z > 0$$ then $$t=1$$;

• if $$z=0$$ then $$t=0$$.

Is this $$z≤Mt$$ sufficient? The $$t$$ and $$z$$ variables are not in my objective function but variable $$t$$ is connected to another variable in the objective function?

Thank you very much, I appreciate your help.

The big-M constraint $$z le M t$$ does enforce $$z > 0 implies t = 1$$, equivalently its contrapositive $$t = 0 implies z = 0$$, but not the converse $$z = 0 implies t = 0. tag1$$ To enforce $$(1)$$, consider its contrapositive $$t = 1 implies z > 0 tag2,$$ which you can enforce via big-M constraint $$epsilon - z le (epsilon - 0)(1 - t),$$ equivalently, $$z ge epsilon t,$$ where $$epsilon > 0$$ is a tolerance that represents the smallest value of $$z$$ that you would consider to be positive.

Correct answer by RobPratt on December 22, 2020

## Related Questions

### How to optimize a utility function that contains step function?

1  Asked on January 5, 2022

### How to display the range of coefficients in docplex log?

1  Asked on January 1, 2022 by ehsank

### Scenario based approach to value-at-risk optimization using mixed-integer programming

1  Asked on January 1, 2022

### Multiple Knapsacks with splitting

1  Asked on December 20, 2021 by cesar-canassa

### How to balance the workload of teachers in OR-Tools (maximization of the minimum)

1  Asked on December 18, 2021 by neverletgo

### How to linearize a quadratic constraint to add it then via a callback function

2  Asked on December 9, 2021 by farouk-hammami

### Decision variable transformation in Gurobi

2  Asked on December 5, 2021

### Possibility of indexing decision variables with 2 indices using a set of tuples in Pyomo

3  Asked on November 24, 2021

### View of Constraints and Decision Variables in Pyomo

1  Asked on November 17, 2021

### CPLEX Python API Manual with References

1  Asked on November 4, 2021

### Are Python and Julia used for optimization in industry?

15  Asked on August 19, 2021

### How to improve the quality of code in OR?

3  Asked on August 19, 2021

### How would you characterize “optimization data?”

4  Asked on August 19, 2021 by marco-lbbecke

### Local optimum of dual of non-linear program

2  Asked on August 19, 2021

### Combinatorial Optimization using AMPL

2  Asked on August 19, 2021 by user3831

### Parallel nonlinear solvers

3  Asked on August 19, 2021 by josh-allen

### Tips on How to Review Operations Research Literature Effectively?

2  Asked on August 19, 2021 by ehsan

### Polynomially solvable cases of zero-one programming

1  Asked on August 19, 2021

### Error evalution for linear fits

1  Asked on August 19, 2021 by jane