Morteza,
If you’re reading the set from GDX into Matlab, why do you want to also enter all the elements in the Matlab source code? Doesn’t that defeat the purpose of reading them from GDX?
If you insist on entering 1, …, 1000 or similar in the Matlab code, you can still see a better way for that in the Matlab code I sent.
-Steve
On Mon, Aug 4, 2014 at 3:45 PM, ‘.::Morteza Shabanzadeh::.’ via gamsworld wrote:
Dear Dr. Dirske,
I am really grateful to you for your prompt answer. But I need to pass on ‘SET’ from GAMS to MATLAB, and not vice versa.
I have a problem with using .uels statement in MATLAB when my SET entries are high (e.g. with 1000 elements). Because ,as I mentioned in my last e-mail, it has to be written as a long line instruction in MATLAB environment (not in GAMS):
SET_name.uels={‘1’,‘2’,‘3’,‘4’,‘5’,‘6’,‘7’,‘8’,‘9’,…too long!..,‘999’,‘1000’};
It seems this kind of statement is not logical in MATLAB programming. But we have a simple instruction in GAMS for high-entry SETs. For example, as you know, we can easily replace the first statement by the second one :
(in GAMS):
-
SET t /1,2,3,4,5,6,7,8,9,…,1000/; (not good for high entries)
-
SET t /1*1000/; (good)
How about equivalent code in MATLAB when we want to use the above-mentioned high-entry SET after passing on to MATLAB?
I look forward to reading your worthwhile answer.
Regards,
Morteza Shabanzadeh
Morteza Shabanzadeh
image
Morteza Shabanzadeh
Researcher » Morteza Shabanzadeh, Tarbiat Modares University, Department of Electrical Engineering, Iran, Electrical Engineering and Electronic Engineering
View on www.researchgate.net
Preview by Yahoo
On Monday, August 4, 2014 6:13 PM, Steven Dirkse wrote:
Morteza,
If you want to construct some set data in Matlab for passing on to GAMS, there are Matlab commands to help with this. The example M-script below illustrates one way.
% --------------------------------------------
mkset = @(s,N) struct(‘name’,s, …
‘uels’,{strcat(cellstr(s),strsplit(num2str(1:N)))});
% --------------------------------------------
si = mkset(‘i’,6);
sj = mkset(‘j’,8);
wgdx(‘example’,si,sj);
On Sun, Aug 3, 2014 at 1:17 PM, ‘.::Morteza Shabanzadeh::.’ via gamsworld wrote:
Hello,
I am going to transfer a ‘SET’ from GAMS into MATLAB.
At first glance, it seems easy if the number of SET elements (entries) is low.
For example, if the number of SET elements is five then it will be easily written in MATLAB as follows
t =struct(‘name’,‘t’,‘value’,[linspace(1,5,5)]',‘type’, ‘set’,‘form’,‘sparse’,‘compress’,‘true’);
t.uels={‘1’,‘2’,‘3’,‘4’,‘5’};
But if the number of SET elements is high (e.g. 200 or 1000), how can I write the line ‘t.uels={‘1’,‘2’,‘3’,…,‘1000’}’ ? It is not logical to write 1000 elements!
I would be grateful if you give me a convincing solution.
Regards,
Morteza Shabanzadeh
وبلاگ شخصی مرتضی شعبان زاده
image
وبلاگ شخصی مرتضی شعبان زاده
وبلاگ شخصی مرتضی شعبان زاده - I live in the present, appreciate the past, and focus on the future - وبلاگ شخصی مرتضی شعبان زاده
View on mortezash.blogfa.com
Preview by Yahoo
\
Steven Dirkse, Ph.D.
GAMS Development Corp., Washington DC
Voice: (202)342-0180 Fax: (202)342-0181
sdirkse@gams.com
http://www.gams.com
Steven Dirkse, Ph.D.
GAMS Development Corp., Washington DC
Voice: (202)342-0180 Fax: (202)342-0181
sdirkse@gams.com
http://www.gams.com