# Decision Optimization

View Only

## Constructing a PWL for Maximization Problem

• #### 1.  Constructing a PWL for Maximization Problem

Posted Tue August 20, 2019 05:24 AM

Originally posted by: FizzaCees

Hello.

I am trying to maximize a function that involves a negatively impacting term, Q:
Max (A - B - C  .. - Q);

Where, A, B, C .. Q are different terms in the objective function that are dependent on decision variables. x1, x2, ... xn (non-negative)I also have the initial positions for the decision variables represented by p1,p2, ... pn and constant values c1,c2, ... cn.

As per my understanding, whether c is positive or negative I have split the decision variables vector x  into two groups (Positive set and Negative set) and calculated the following:

P = sum(j in Postive set)
mypwl(pj -xj) *cj
N = sum(j in Negative set)
mypwl(pj -xj) *cj

Q is defined as:
Q =  P+N + Switch;

Where, mypwl is a piece-wise function defined as follows:

pwlFunction mypwl=piecewise{0->0; 0->0; 1};

Intuitively, I would like to penalize the positive values under all circumstances, and give preference to negative values or "switch them off" under specific circumstances (e.g. sum of P and N is less than zero)

Here, Switch is a decision variable which can either be zero OR equal to - N, bounded through constraints as follows:
constraint_1 :(P+N >= 0) => (Switch == 0);
constraint_2 :!(P+N >= 0) => (Switch == -N); //(negation constraint)

I am trying to continue to penalize positive values but stop the preference for negative values when N>P (this is achieved through constraint_2).
However, this seems to be an incorrect implementation of the problem I am trying to model. To explain this, let's go over an example :

If N= -400 and P =200
then
Q = 200 +(-400) + 400 = 200

Increasing the value of P will increase the value of Q until P>N at which point the switch will revert to a value of 0 and Q = 401 -400 =1.
This would incentivize the optimization to target a Q value of 0 rather than letting the expressions A,B, C .. take control of the optimization.
I believe the implementation can be improved by fixing the value of N when P==N, rather than using switch however I am unsure as to how one can achieve this. Please advise on how to achieve this, any alternate solution to achieve the same outcome would also be greatly appreciated.

#DecisionOptimization
#MathematicalProgramming-General

• #### 2.  Re: Constructing a PWL for Maximization Problem

Posted Wed August 28, 2019 08:16 AM

Hi,

in order to help with the initial positions you could use warm start :

You are allowed to write

constraint_1 :(P+N >= 0) => (Switch == 0);
constraint_2 :!(P+N >= 0) => (Switch == -N); //(negation constraint)

regards

#DecisionOptimization
#MathematicalProgramming-General

• #### 3.  Re: Constructing a PWL for Maximization Problem

Posted Thu September 05, 2019 03:30 AM

Originally posted by: FizzaCees

Thank you for the response!

As you said:

You are allowed to write

constraint_1 :(P+N >= 0) => (Switch == 0);
constraint_2 :!(P+N >= 0) => (Switch == -N); //(negation constraint)

I am actually using these constraints just like I mentioned in my post, however, it does not yield the results I require (penalizing positives in all scenarios).

Any help with this would be appreciated.