07-23-2018
Hendrik
Calcite | Level 5
Member since
07-11-2018
- 14 Posts
- 1 Likes Given
- 0 Solutions
- 0 Likes Received
-
Latest posts by Hendrik
Subject Views Posted 2490 07-20-2018 09:28 AM 2512 07-19-2018 10:35 AM 2533 07-17-2018 03:06 PM 1509 07-17-2018 02:42 PM 1526 07-16-2018 02:16 PM 1532 07-16-2018 01:44 PM 2569 07-16-2018 01:01 PM 1576 07-12-2018 05:53 PM 2936 07-12-2018 08:46 AM 2963 07-11-2018 05:55 PM -
Activity Feed for Hendrik
- Liked Re: Constraint setup for skills/abiities/assignment in bin packing problem optmodel for RobPratt. 07-20-2018 02:17 PM
- Posted Re: Constraint setup for skills/abiities/assignment in bin packing problem optmodel on Mathematical Optimization, Discrete-Event Simulation, and OR. 07-20-2018 09:28 AM
- Posted Re: Constraint setup for skills/abiities/assignment in bin packing problem optmodel on Mathematical Optimization, Discrete-Event Simulation, and OR. 07-19-2018 10:35 AM
- Posted Re: Constraint setup for skills/abiities/assignment in bin packing problem optmodel on Mathematical Optimization, Discrete-Event Simulation, and OR. 07-17-2018 03:06 PM
- Posted Re: Data handling and constraint setting for bin packing optmodel example on Mathematical Optimization, Discrete-Event Simulation, and OR. 07-17-2018 02:42 PM
- Posted Re: Data handling and constraint setting for bin packing optmodel example on Mathematical Optimization, Discrete-Event Simulation, and OR. 07-16-2018 02:16 PM
- Posted Re: Data handling and constraint setting for bin packing optmodel example on Mathematical Optimization, Discrete-Event Simulation, and OR. 07-16-2018 01:44 PM
- Posted Constraint setup for skills/abiities/assignment in bin packing problem optmodel on Mathematical Optimization, Discrete-Event Simulation, and OR. 07-16-2018 01:01 PM
- Posted Data handling and constraint setting for bin packing optmodel example on Mathematical Optimization, Discrete-Event Simulation, and OR. 07-12-2018 05:53 PM
- Posted Re: Program removes duplicates that are no duplicates on Statistical Procedures. 07-12-2018 08:46 AM
- Posted Re: Program removes duplicates that are no duplicates on Statistical Procedures. 07-11-2018 05:55 PM
- Posted Re: Program removes duplicates that are no duplicates on Statistical Procedures. 07-11-2018 12:49 PM
- Posted Program removes duplicates that are no duplicates on Statistical Procedures. 07-11-2018 11:07 AM
- Posted Re: Display program output of bin packing example on SAS Programming. 07-11-2018 10:14 AM
- Posted Display program output of bin packing example on SAS Programming. 07-11-2018 09:46 AM
-
Posts I Liked
07-20-2018
09:28 AM
Hi Rob, Sorry for the confusion with my files. I updated my post and the files. Thank you also for mentioning the EXPAND statement, I will take a look at that. Hendrik
... View more
07-19-2018
10:35 AM
I just noticed that the skills constraint does not work. There are a few things that changed from the initial code, but those are only small changes. Could it be, that the code works fine, but the bins/technicians are shown in a different order in the final solution? proc import datafile = '\\...\falk_u250_125_bin_skills2.csv'
out = tech_skills
dbms = CSV
;
run;
proc import datafile = '\\...\falk_u250_125.csv'
out = falk_u250test125
dbms = CSV
;
run;
data mytech_skills;
set work.tech_skills;
run;
data myContent;
set work.falk_u250test125;
run;
proc print data=mytech_skills(keep= bin_num skill0 skill1 skill2 skill3 skill4 skill5 skill6 skill7 skill8 skill9);
run;
proc print data=myContent(keep= Jobs u250_00 u250_00skills_req); /* Jobs length skills_required */
run;
proc optmodel;
/* read the product and size data */
set <str> JOBS;
num u250_00 {JOBS};
num u250_00skills_req {JOBS};
read data myContent into JOBS=[Jobs] u250_00 u250_00skills_req;
set SKILLS = setof {j in JOBS} u250_00skills_req[j];
set <num> TECHS;
num has_skill {TECHS, SKILLS};
read data mytech_skills into TECHS=[bin_num] {s in SKILLS} <has_skill[bin_num,s]=col('skill'||s)>;
print has_skill;
/* time/tech */
num binsize = 150;
/* the number of products is a trivial upper bound on the
number of bins needed */
num upperbound init card(JOBS);
set BINS = 1..upperbound;
set TECHS_j {j in JOBS} = {t in TECHS: has_skill[t,u250_00skills_req[j]] = 1};
/* Assign[p,b] = 1, if product p is assigned to bin b */;
var Assign {j in JOBS, TECHS_j[j]} binary;
/* UseBin[b] = 1, if bin b is used */
var UseBin {TECHS} binary;
/* minimize number of bins used */
min Objective = sum {t in TECHS} UseBin[t];
/* Skills constraint: A tech/bin can only accomodate a job if he/she has the required skill */
con SkillsCon {j in JOBS}:
sum{t in TECHS_j[j]} Assign[j,t] = 1;
/* Capacity constraint on each bin (and definition of UseBin) */
con Capacity {t in TECHS}:
sum {j in JOBS: has_skill[t,u250_00skills_req[j]] = 1}u250_00[j] * Assign[j,t] <= binsize * UseBin[t];
/* decompose by bin (subproblem is a knapsack problem) */
for {t in TECHS} Capacity[t].block = t;
/* solve using decomp (aggregate formulation) */
solve with milp / decomp;
/* create a map from arbitrary bin number to sequential bin number */
num binId init 1;
num binMap {TECHS};
for {t in TECHS: UseBin[t].sol > 0.5} do;
binMap[t] = binId;
binId = binId + 1;
end;
/* create map of product to bin from solution */
num bin {JOBS};
for {j in JOBS} do;
for {t in TECHS_j[j]: Assign[j,t].sol > 0.5} do;
bin[j] = binMap[t];
leave;
end;
end;
/* create solution data */
create data jobAssignments from [product] bin u250_00 u250_00skills_req;
/*print bin length;*/
quit;
proc sort data=jobAssignments;
by bin;
run;
proc print data=jobAssignments noobs;
by bin;
sum u250_00;
run;
... View more
07-17-2018
03:06 PM
Thank you Rob, As the rest of ,my program has a slightly different structure, I get the following invalid array message now. 4610 /* Assign[p,b] = 1, if product p is assigned to bin b */; 4611 var Assign {j in JOBS, TECHS_j[j]} binary; 4612 4613 /* UseBin[b] = 1, if bin b is used */ 4614 var UseBin {TECHS} binary; 4615 4616 /* minimize number of bins used */ 4617 min Objective = sum {t in TECHS} UseBin[t]; 4618 4619 /* assign each product to exactly one bin */ 4620 con Assignment {j in JOBS}: 4621 sum {t in TECHS_j[j]} Assign[j,t] = 1; 4622 4626 4627 /* Capacity constraint on each bin (and definition of UseBin) */ 4628 con Capacity {t in TECHS}: 4629 sum {j in JOBS} length[j] * Assign[j,t] <= binsize * UseBin[t]; 4630 4631 /* decompose by bin (subproblem is a knapsack problem) */ 4632 for {t in TECHS} Capacity[t].block = t; 4633 4634 /* solve using decomp (aggregate formulation) */ 4635 solve with milp / decomp; NOTE: Problem generation will use 4 threads. ERROR: The array subscript 'Assign[t9qe9c,1]' is invalid at line 4629 column 39. ERROR: The array subscript 'Assign[t9qe9c,2]' is invalid at line 4629 column 39. ERROR: The array subscript 'Assign[t9qe9c,3]' is invalid at line 4629 column 39. ERROR: The array subscript 'Assign[t9qe9c,4]' is invalid at line 4629 column 39. NOTE: Unable to create problem instance due to previous errors. 4636 4637 /* create a map from arbitrary bin number to sequential bin number */ 4638 num binId init 1; 4639 num binMap {TECHS}; 4640 for {t in TECHS: UseBin[t].sol > 0.5} do; 4641 binMap[t] = binId; 4642 binId = binId + 1; 4643 end; 4644 4645 /* create map of product to bin from solution */ 4646 num bin {JOBS}; 4647 for {j in JOBS} do; 4648 for {t in TECHS_j[j]: Assign[j,t].sol > 0.5} do; 4649 bin[j] = binMap[t]; 4650 leave; 4651 end; 4652 end; 4653 4654 /* create solution data */ 4655 create data jobAssignments from [product] bin length skills_required; NOTE: The data set WORK.JOBASSIGNMENTS has 124 observations and 4 variables. 4656 4657 /*print bin length;*/ 4658 quit; Out of the error message, I can see that the mistake lies in line 4629 (the bin capacity constraint). I guess that the '{t in TECHS}' in the previous line causes this. But how do I correctly formulate this?
... View more
07-16-2018
02:16 PM
Thank you for your quick reply Rob! This works fine and I noticed, I should have asked the question differently... Is it possible to iterate through these parameters (in array shape)? For example: for all i in rows: for all j in columns: put arrayelement[i,j] Thank you in advance, Hendrik
... View more
07-16-2018
01:44 PM
Thank you for your answer Rob! Based on this, how do I access the parameter? For example, if I would like to print the rating of FSU, is there a way to say 'put PRODUCTS[5,3]?
... View more
07-16-2018
01:01 PM
Hi, I am setting up an optmodel where jobs have to be assigned to technicians, but only those, who have the ability/skill required. This is similar to a job shop scheduling model where some tasks can only be executed by certain machines. My input data consists of two arrays, a list of jobs array that contains all jobs and required skill per job (1) and a tech_skills array that contains the skills a technician has (2). The format is as follows: Job list array (PRODUCTS): technician_skills array (SKILLS): My data is stored as follows: proc optmodel; /* read the product and size data */ set <str> PRODUCTS; num length {PRODUCTS}; num skills_required {PRODUCTS}; read data myContent into PRODUCTS=[Jobs] length skills_required; /* read the tech and skills data */ set <num> SKILLS; num _10001 {SKILLS}; num _10002 {SKILLS}; num _10003 {SKILLS}; num _10004 {SKILLS}; num _10005 {SKILLS}; num _10006 {SKILLS}; num _10007 {SKILLS}; num _10008 {SKILLS}; num _10009 {SKILLS}; num _10010 {SKILLS}; read data mytech_skills into SKILLS=[TechID] _10001 _10002 _10003 _10004 _10005 _10006 _10007 _10008 _10009 _10010; I would like to set up a constraint that only allows the allocation of a job to a bin/machine/technician if the skill requirement is met. I imagine it should have the following structure: for all j in JOBS: for all s in SKILLS: Tech_skills[ s ][ skills_required[j] ] * decision variable = 1; The decision variable determines whether a job is executed by a technician or not (0,1). I tried a couple or variants, but I think I do not access the variables correctly: con SkillsCon {p in PRODUCTS}: sum{b in BINS} SKILLS[b, skills_required[p]] * Assign[p,b] = 1; Please let me know if any information is missing.
... View more
07-12-2018
05:53 PM
Hi, I am setting up a bin packing model based on the SAS example (http://support.sas.com/documentation/cdl/en/ormpug/67517/HTML/default/viewer.htm#ormpug_decomp_examples06.htm) The data definition step looks as follows: data dvr; input opponent $ size; datalines; Clemson 1.36 Clemson2 1.97 Duke 2.76 Duke2 2.52 FSU 2.56 FSU2 2.34 GT 1.49 [...] ; I am new to SAS and don't really know how to access the data. In my application, I have a third value (rating) for each data row as follows: data dvr; input opponent $ size $ rating; datalines; Clemson 1.36 1 Clemson2 1.97 2 Duke 2.76 3 Duke2 2.52 3 FSU 2.56 2 FSU2 2.34 1 GT 1.49 2 [...] I thought that I can call these values like using an array but it does not work. I would like to set up a constraint that compares the third value to another value and sets up a constraint. If anybody could help me and give a hint on how I can access or loop though these values, it would be amazing!
... View more
07-12-2018
08:46 AM
Thank you! I did not know that SAS looks at the first 20 values to estimate the variables. In my case, the variable names were 'Job' + # which resulted in 6 instead of 5 characters for values from 100. If the variable length was set to $5 before, the last character was automatically cut of and hence, the duplicates were found and eliminated.
... View more
07-11-2018
05:55 PM
The Jobs column of the dataset is created in Excel with an autofill (drag down) option. So far, the only way to avoid the duplicate deletion is to insert random names for the jobs and work with that. As I thought that maybe SAS automatically reduces the number of used signs to '5', I also tried to manually set it to '6' during the data import: data myContent; length var $6; set work.falk_u250test; run; However, it does not work either
... View more
07-11-2018
12:49 PM
Thanks Suryakiran, I first thought, that the variables are shortened to a default length of 5, but I changed the names and SAS still removes quite a lot. Here is the first part of my code until the error occurs: data myContent; set work.falk_u250test; run; proc print data=myContent(keep= Jobs length); run; proc optmodel; /* read the product and size data */ set <str> PRODUCTS; num length {PRODUCTS}; read data myContent into PRODUCTS=[Jobs] length; [...] quit; Could it be some default setting of the 'optmodel'?
... View more
07-11-2018
11:07 AM
Hi, I have a program that reads data which has to be processed, the data consists of two columns (Jobs, length) with Jobs rows as follows = (Job1, Job2, ...., Job250). SAS seems to falsely identifying duplicate rows (i.e. Job100 is a duplicate of Job 10). The following screenshot shows the line of code and duplicate message: How do I specify the way duplicates are identified and where do I embed this in my code? Thank you in advance!
... View more
07-11-2018
10:14 AM
Thank you, this works, but is possible to print it in the format of the example as well (see below)?
... View more
07-11-2018
09:46 AM
Hi, I am new to SAS and tried to set up a bin packing program based on the example from the user's guide (link). The program runs without errors, however, the optimal solution is not printed/displayed. I think that this piece of code is sorting the results: proc sort data=dvd; by bin; run; I don't know if a print statement is necessary, it is not stated in the example. Thank you in advance!
... View more