一.集
1.原始集
(1)显式罗列
sets:
set/1,2,3/:x;
endsets
(2)隐式罗列
sets:
set/1..3/:x;
endsets
2.派生集
(1)稠密集
sets:
set1/1..3/;
set2/2,5,7/;
link(set1,set2):x;
endsets
(2)稀疏集
1)显式罗列
sets:
set1/1..3/;
set2/2,5,7/;
link(set1,set2)/1,2,2,5,3,7/:x;
endsets
2)隐式罗列
sets:
set1/1..3/;
set2/2,5,7/;
link(set1,set2)|&1 #ge# 2 #and# &2 #lt# 7 :x;
endsets
!第1个索引小于等于2,第2个索引小于等于7;
二.数据部分
1.数据赋值
sets:
set/1..4/:t,w;
endsets
data:
t = 13,16,19,15;
w = 42,51,61,53;
enddata
2.输入数据
sets:
set/1..4/:t,w;
endsets
data:
t = 13,16,19,15;
w = 42,51,61,?;
enddata
3.初始段
init:
c = 0;
d = 1;
endinit
三.常用运算符和函数
1.运算符
#eq# #ne# #gt# #ge# #lt# #le#
2.函数
(1)@free():任意实数 @gin():非负整数 @bin():0或1
x = 1/3;
@free(y);
y = @log(x);
(2)@if()
min = f+g;
f = @if(x #gt# 0,100+2*x,2*x);
g = @if(y #gt# 0,60+3*y,3*Y);
x + y >= 30;
@free(x);
@free(y);
@free(f):
@free(g);
(3)集循环函数:@for,@sum,@max,@min
sets:
set/1..6/:x,y,z;
endsets
data:
x = 1,2,3,4,5,6;
enddata
@for(set:y = x);
@for(set(i)|i #le# 3:z(i) = x(i)+3);
@for(set(i)|i #gt# 3:z(i) = x(i)-3);
s = @sum(set(i)|i #le# 4:x(i));
maxn = @max(set(i):x);
minn = @min(set(i)|i #le# 3:z(i));
(4)@bnd()
sets:
set/1..3/:x,f;
endsets
min = @sum(set:f);
f(1) = 2*x(1)^2+3*x(1)+1;
f(2) = x(2)^2+4*x(2)+2;
f(3) = x(3)^2+x(3)+6;
@sum(set:x) = 3500;
@for(set:@bnd(30,x,1600));
(5)输出函数:@text(),@table()
sets:
set/1..6/:x;
endsets
data:
x = 1,2,3,4,5,6;
@text('data1.txt') = x;
@text() = @table(x);
enddata
(6)输入函数:@file(),@ole()