# Decision Optimization

View Only

## Objective as Piecewise Linear Function

• #### 1.  Objective as Piecewise Linear Function

Posted Mon November 22, 2021 11:20 AM
Hi,

I am working on an optimization model using CPLEX Java API. My objective function is to minimize number of lost trips lit for each location i and time window t.
nit  is the decision variable that denotes number of vehicles to be positioned at location i for time window t. After running simulations through an external application, I have obtained the number of lost trips by varying number of vehicles from 5, 10, ... till 100. This data is available for each location and for every time window.

Any insights on how the objective function could be formulated as a piecewise linear function or by any other approach would be really helpful.

Thanks and regards,
Saumya

------------------------------
Saumya Bhatnagar
------------------------------

• #### 2.  RE: Objective as Piecewise Linear Function

Posted Mon November 22, 2021 12:01 PM
If you are asking about how to implement a PWL function in a CPLEX model (as opposed to how to fit one to your data), I would recommend checking the user manual, specifically CPLEX Optimizers > User's Manual for CPLEX > Discrete Optimization > Using piecewise linear functions in optimization: a transport example.

------------------------------
Paul Rubin
Professor Emeritus
Michigan State University
------------------------------

• #### 3.  RE: Objective as Piecewise Linear Function

Posted Tue November 23, 2021 03:30 AM
Hi Prof. Paul,

Thanks for the response. The transport example is really helpful. Are there any examples/resources that explain how to populate data into the PWL function?

Best regards,
Saumya

------------------------------
Saumya Bhatnagar
------------------------------

• #### 4.  RE: Objective as Piecewise Linear Function

Posted Tue November 23, 2021 11:03 AM
There's the one mentioned in the manual. From your CPLEX Studio main directory, drill down to cplex/examples/src/java and look at Transport.java.

------------------------------
Paul Rubin
Professor Emeritus
Michigan State University
------------------------------

• #### 5.  RE: Objective as Piecewise Linear Function

Posted Wed November 24, 2021 12:27 AM
Hi Prof. Paul,

Thanks for the clarification.

Best regards,
Saumya

------------------------------
Saumya Bhatnagar
------------------------------