‎2013 Feb 20 1:14 PM
Hi Experts,
Is ABAP supporting linear/ nonlinear programming.
If yes, please tell me the method and how can I solve the below problem using linear/nonlinear programming.
I have solved it by normal ABAP but it is very slow.
I have below two table's values.
1st Table values.
51
82
143
2nd Tables value is
1007
I want to consume the full value 1007 based on multiple combinations of 1st table's values.
I want the set of combinations results as below:
Combination 1. 51 x 19 = 969(consume), 38 (Balance)
Combination 2. 51 x 18 + 82 x 1 = 1000(Consume), 7 (Balance)
Combination 3. 51 x 16 + 81 x 2 = 980(Consume), 27 (Balance)
Combination 4. 51 x 16 + 143 x 1 = 959(Consume), 48 (Balance)
Combination 5. 51 x 15 + 82 x 1 + 143 x 1 = 990(Consume), 17 (Balance)
And so on.....
Thanks,
‎2013 Feb 20 1:28 PM
Hello Narendra,
there is a standard-framework for such operations-research algorithm.
Look in this very detailed blog: http://scn.sap.com/community/abap/blog/2011/10/04/operations-research-abap
Have fun!
Kind regards,
Hendrik
‎2013 Feb 21 8:31 AM
Hello Hendrik,
Thanks for reply, I know about this research technique but I am not able to use it because I don't know about this programming.
I don't know how to use it in my scenario. will you please provide me some sample code based on my scenario with my data.
Thanks
Narendra.
‎2013 Feb 22 7:13 AM
hi,
can anyone solve my problem. is there any way to solve this problem.
‎2013 Feb 22 9:15 AM
‎2013 Feb 22 1:05 PM
TYPES: BEGIN OF ty_values,
count TYPE i,
value1 TYPE i,
multi1 TYPE i,
value2 TYPE i,
multi2 TYPE i,
value3 TYPE i,
multi3 TYPE i,
result TYPE i,
balance TYPE i,
END OF ty_values.
PARAMETERS: p_1 TYPE i DEFAULT 51,
p_2 TYPE i DEFAULT 82,
p_3 TYPE i DEFAULT 143,
p_4 TYPE i DEFAULT 1007.
DATA: lt_tab TYPE TABLE OF ty_values,
wa_tab TYPE ty_values,
lv_max_comb_1 TYPE i,
lv_max_comb_2 TYPE i,
lv_max_comb_3 TYPE i,
lv_max_comb TYPE i,
lv_count TYPE i,
lv_count1 TYPE i,
lv_count2 TYPE i,
lv_count3 TYPE i,
lv_result TYPE i,
lv_balance TYPE i,
lv_next TYPE i.
START-OF-SELECTION.
lv_count = 0.
lv_next = 1.
lv_count1 = 0.
lv_count2 = 0.
lv_count3 = 0.
DO.
CLEAR: lv_result, lv_balance.
lv_result = p_1 * lv_count1
+ p_2 * lv_count2
+ p_3 * lv_count3.
lv_balance = p_4 - lv_result.
IF lv_balance < 0.
IF lv_next = 4.
EXIT.
ELSE.
lv_next = lv_next + 1.
CASE lv_next.
WHEN 2.
lv_count2 = lv_count2 + 1.
lv_count1 = 0.
WHEN 3.
lv_count3 = lv_count3 + 1.
lv_count2 = 0.
lv_count1 = 0.
ENDCASE.
CONTINUE.
ENDIF.
ELSE.
wa_tab-count = lv_count.
wa_tab-value1 = p_1.
wa_tab-value2 = p_2.
wa_tab-value3 = p_3.
wa_tab-multi1 = lv_count1.
wa_tab-multi2 = lv_count2.
wa_tab-multi3 = lv_count3.
wa_tab-result = lv_result.
wa_tab-balance = lv_balance.
APPEND wa_tab TO lt_tab.
CLEAR wa_tab.
lv_count = lv_count + 1.
lv_count1 = lv_count1 + 1.
ENDIF.
ENDDO.
SORT lt_tab BY balance.
lv_count = 0.
LOOP AT lt_tab INTO wa_tab.
lv_count = lv_count + 1.
WRITE: / 'Combination ', lv_count, ': ',
p_1, ' x ', wa_tab-multi1, ' + ',
p_2, ' x ', wa_tab-multi2, ' + ',
p_3, ' x ', wa_tab-multi3, ' = ', wa_tab-result,
' Balance: ', wa_tab-balance.
ENDLOOP.
‎2013 Feb 22 5:15 PM
We tried to do some of this about 3 years ago and could not find a good way to do it either. At that time the APO landscape had some features for linear programming. You may want to see if it has advanced since then.
Regards,
Steve
I was wrong it was four years ago. Here's the thread in case it helps.