Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 12-13-2017 02:08 PM
(702 views)

Hi,

I want to use something similar to Heaviside function to create a unit pulse. Unit pulse is required because I want to define some objective function and constraint which are piece-wise linear. For example from x=0 to 10, y=x , x>=10 , y=20-x. I am unable to find out a function which could help me to write such formulation without having to write multiple if-else statement.

3 REPLIES 3

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Does your x variable have an upper bound? Is the rest of your optimization model linear?

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

If y - x is in [-M_1,M_1] and y - (20 - x) is in [-M_2,M_2] for suitably chosen constants M_1 and M_2, you can linearize the relationship between x and y by introducing a binary variable z and the following constraints:

-M_1 * z <= y - x <= M_1 * z

-M_2 * (1 - z) <= y - (20 - x) <= M_2 * (1 - z)

If z = 0, the first pair of constraints force y = x. If z = 1, the second pair of constraints force y = 20 - x.

Depending on your objective and other constraints, you might be able to avoid the bounds and binary variables. For example, if you want to maximize y, you can just impose y <= x and y <= 20 - x.

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

**If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. **

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.