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

Syntax for 'proc optmodel': Sum - Sum ...

Reply
New User
Posts: 1

Syntax for 'proc optmodel': Sum - Sum ...

Having trouble with defining a constraint for optimization model:

 

- keeps 'sum' - 'sum' not working .... ideas?

 

proc optmodel;
	set Hor_Nodes={'1H', '2H', '3H', '4H', '5H'};
	set Ver_Nodes={'1V', '2V', '3V', '4V', '5V'};
	number Matrix{Ver_Nodes,Hor_Nodes}=[
	0 3 4 5 0
	3 0 0 0 7
	4 0 0 2 4
	5 0 2 0 1 
	0 7 4 1 0];
	
	var x{Ver_Nodes, Hor_Nodes}>=0;
	
	min z = sum{i in Hor_Nodes}(sum{j in Ver_Nodes}x[j,i]*Matrix[j,i]);
	
	con Flow_const{j in Ver_Nodes}: sum{i in Hor_nodes}x[j,i] -sum{i in Ver_Nodes}x[i,j]=0;
	
	solve;
	
	print Matrix;
	print z;
	
quit;
SAS Employee
Posts: 449

Re: Syntax for 'proc optmodel': Sum - Sum ...

Your constraint refers to variables that don't exist, and that is why you get these error messages:

ERROR: The array subscript 'x['1V','1V']' is invalid at line 15 column 82.
ERROR: The array subscript 'x['1V','2V']' is invalid at line 15 column 82.
ERROR: The array subscript 'x['1V','3V']' is invalid at line 15 column 82.
ERROR: The array subscript 'x['1V','4V']' is invalid at line 15 column 82.

 

I think you might need to collapse your Hor_nodes and Ver_nodes into a single set of nodes, as in this documentation example.  But if all your supplies and demands are 0, the trivial solution with x[j,i] = 0 everywhere is optimal.  Maybe it would help to take a step back and describe your business problem in words without any algebra.

Ask a Question
Discussion stats
  • 1 reply
  • 128 views
  • 0 likes
  • 2 in conversation