Operations Research topics: SAS/OR,
SAS Optimization, and SAS Simulation Studio

Constraint with more than 2 elements in tupple

Reply
New Contributor
Posts: 4

Constraint with more than 2 elements in tupple

[ Edited ]

Hi,

 

I am running below mentioned code...

 

proc optmodel;

ods output SolutionSummary=exss;

 

set <string> itm_list;
set <string,string,string,string> itm_hrchy;
set <string,string,string,string,string,string,number,number> dsp_prc_choice;

 

number beg_stk{itm_list};
number curr_dsp{itm_hrchy};
number cogs{dsp_prc_choice};
number org_prc{dsp_prc_choice};
number sugg_prc{dsp_prc_choice};
number sugg_dsp{dsp_prc_choice};
number qty{dsp_prc_choice};

 

read data table1
into itm_list=[itm_cd] a=...;

 

read data table2
into itm_hrchy=[grp_cd dpt_cd cls_cd sbcls_cd] v=...;

 

read data table3
into dsp_prc_choice=[grp_cd dpt_cd cls_cd sbcls_cd curr_ssn_cd itm_cd display_str sug_rtl_prc] qty=&qty_value. k=... l=... n=... m=...;

 

var x {<grp,dpt,cls,sbcls,ssn,itm,dsp,prc> in dsp_prc_choice} binary;

 

max obj = ...

 

con1 ...;

con2 ...;

 

con sbcls_dsp{grp,dpt,cls,sbcls in itm_hrchy}: sum{<(grp,dpt,cls,sbcls),ssn,itm,dsp,prc> in dsp_prc_choice} m[grp,dpt,cls,sbcls,ssn,itm,dsp,prc]*x[grp,dpt,cls,sbcls,ssn,itm,dsp,prc] = v[grp,dpt,cls,sbcls];

 

con3 ...;

 

solve with milp / relobjgap=0.1;

 

create data solution from [grp_cd dpt_cd cls_cd sbcls_cd curr_ssn_cd itm_cd sugg_dsp_str sugg_rtl_prc] = {<grp,dpt,cls,sbcls,ssn,itm,dsp,prc> in dsp_prc_choice: x[grp,dpt,cls,sbcls,ssn,itm,dsp,prc] = 1};

run;

 

I am getting error in the "sbcls_dsp" constraint declaration. Following error is coming -

 

72 con sbcls_dsp{grp,dpt,cls,sbcls in itm_hrchy}: sum{<(grp,dpt,cls,sbcls),ssn,itm,dsp,prc> in dsp_prc_choice}
___ _ _ _ _ _ _ ___
_
___
_
___
_
525 515 515 516 22 79 702 525
621
525
621
525
621
781
ERROR 525-782: The symbol 'grp' is unknown.

ERROR 516-782: The indexing does not match the set element length, 1 NE 4.

ERROR 22-322: Syntax error, expecting one of the following: (, ).

ERROR 79-322: Expecting a ).

3 The SAS System 09:38 Monday, November 28, 2016

ERROR 702-782: The slice value type, a number, does not match the set element 1 type, a string.

ERROR 621-782: Subscript 1 must be a string, found a number.

ERROR 781-782: Null argument is not allowed for function 'GRP'.

_ ___
515 534
ERROR 515-782: An indexing set subexpression may not be a number.

ERROR 534-782: The function 'grp' is unknown.

72 ! con sbcls_dsp{grp,dpt,cls,sbcls in itm_hrchy}: sum{<(grp,dpt,cls,sbcls),ssn,itm,dsp,prc> in dsp_prc_choice}
___ ___ _
___
_
___
_
___
_
525 525 516
525
621
525
621
525
621
ERROR 525-782: The symbol 'dpt' is unknown.

ERROR 516-782: The indexing does not match the set element length, 5 NE 8.

ERROR 621-782: Subscript 2 must be a string, found a number.

72 ! con sbcls_dsp{grp,dpt,cls,sbcls in itm_hrchy}: sum{<(grp,dpt,cls,sbcls),ssn,itm,dsp,prc> in dsp_prc_choice}
___ ___
___
_
___
_
___
_
525 525
525
621
525
621
525
621
ERROR 525-782: The symbol 'cls' is unknown.

ERROR 621-782: Subscript 3 must be a string, found a number.

72 ! con sbcls_dsp{grp,dpt,cls,sbcls in itm_hrchy}: sum{<(grp,dpt,cls,sbcls),ssn,itm,dsp,prc> in dsp_prc_choice}
72 ! m[grp,dpt,cls,sbcls,ssn,itm,dsp,prc]*x[grp,dpt,cls,sbcls,ssn,itm,dsp,prc] = v[grp,dpt,cls,sbcls];
_ _
621 621
ERROR 621-782: Subscript 7 must be a number, found a string.

4 The SAS System 09:38 Monday, November 28, 2016

72 ! m[grp,dpt,cls,sbcls,ssn,itm,dsp,prc]*x[grp,dpt,cls,sbcls,ssn,itm,dsp,prc] = v[grp,dpt,cls,sbcls];
_ _
621 621
ERROR 621-782: Subscript 8 must be a number, found a string.

73
74 con must_allocate_price{itm in itm_list}: sum{<grp,dpt,cls,sbcls,ssn,(itm),dsp,prc> in dsp_prc_choice}
74 ! x[grp,dpt,cls,sbcls,ssn,itm,dsp,prc] = 1;
75
76 solve with milp / relobjgap=0.1;
NOTE: Problem generation will use 28 threads.
NOTE: Previous errors might cause the problem to be resolved incorrectly.
ERROR: The constraint 'sbcls_dsp' has an incomplete declaration.

SAS Employee
Posts: 416

Re: Constraint with more than 2 elements in tupple

You are missing some angle brackets and parentheses.  Try this:

   con sbcls_dsp{<grp,dpt,cls,sbcls> in itm_hrchy}:
      sum{<(grp),(dpt),(cls),(sbcls),ssn,itm,dsp,prc> in dsp_prc_choice} 
Ask a Question
Discussion stats
  • 1 reply
  • 124 views
  • 0 likes
  • 2 in conversation