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

Operations Research Asked on January 5, 2022

I have an optimization problem with an uncommon utility: to find a $$beta$$ that maximizes

$$r^{T}cdot H(Xcdotbeta)$$

where $$H()$$ is a Heaviside step function as in wiki

$$r$$ is a vector of size 1000

$$X$$ is a 1000×50 "tall" matrix

$$beta$$ is a vector of size 50

I am familiar with gradient descent, which is how I usually solve an optimization problem. But Heaviside function does not work with gradient descent. So I am wondering if anyone here could shed some light on how to solve such optimization problem.

You can solve the problem via integer linear programming as follows, assuming $$r_i ge 0$$ for all $$i$$. Let $$M_i$$ be a (small) upper bound on $$-(X cdot beta)_i$$. Let binary decision variable $$y_i$$ indicate whether $$(X cdot beta)_i ge 0$$. The problem is to maximize $$sum_{i=1}^{1000} r_i y_i$$ subject to $$-(X cdot beta)_i le M_i(1 - y_i)$$ for all $$i$$. This "big-M" constraint enforces $$y_i=1 implies (X cdot beta)_i ge 0$$.

Answered by RobPratt on January 5, 2022

## 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