로드 중...
검색 중...
일치하는 항목 없음
Clad.java
1패키지com.슬롯 게임examples.clad;
2
3가져오기java.io.BufferedWriter;
4가져오기java.io.ByteArrayOutputStream;
5가져오기java.io.파일;
6가져오기java.io.FileWriter;
7가져오기java.io.PrintStream;
8가져오기java.util.AbstractMap;
9가져오기java.util.ArrayList;
10가져오기java.util.List;
11가져오기java.util.Map;
12
14가져오기 com.감스.API.GAMSJob;
17가져오기 com.게임.API.GAMSWorkspaceInfo;
18
32공개 클래스클래드{
33
34 공개 정적 무효메인(문자열[] 인수)
36 if(args.length > 0)
37wsInfo.setSystemDirectory( 인수[0] );
38
39파일 WorkingDirectory =신규파일(System.getProperty("user.dir"), "클래드");
40workingDirectory.mkdir();
41wsInfo.setWorkingDirectory(workingDirectory.getAbsolutePath());
42
44
45목록<Map.Entry<Long,String>> 단계 =신규ArrayList<Map.Entry<Long,String>>();
46단계.추가(신규AbstractMap.SimpleEntry<긴 문자열>(신규긴(5),"epgap 0.1") );
47단계.추가(신규AbstractMap.SimpleEntry<긴 문자열>(신규장(10),"epgap 0.2"));
48단계.추가(신규AbstractMap.SimpleEntry<긴 문자열>(신규장(20),"epagap 1e9"));
49
50 GAMSJob직업 = ws.addJobFromGamsLib("입은");
51
52 시도해 보세요{
53파일 로그파일 =신규파일(ws.workingDirectory(), "cplex.opt");
54BufferedWriter 아웃파일 =신규버퍼링라이터(신규파일 작성기(로그파일));
55outfile.write("epgap 0"); outfile.newLine();
56outfile.write("대화형 1"); outfile.newLine();
57outfile.write("iafile cplex.op2"); outfile.newLine();
58outfile.close();
59}잡기(예외 e)
60e.printStackTrace();
61System.exit(1);
62}
63
64GAMSOptions opt = ws.추가옵션();
65선택.setMIP( "복합체");
66opt.setOptFile( 1 );
67opt.setSolveLink( GAMSOptions.ESolveLink.LoadLibrary );
68opt.setThreads( 1 );
69
70ByteArrayOutputStream os =신규ByteArrayOutputStream();
71PrintStream ps =신규PrintStream(os);
72
73근로자 w =신규근로자(직업, 선택, ps);
74w.start();
75
76 prevStep = 0;
77 for(Map.Entry<Long, String> 항목 : 단계)
78 diffInSeconds =entry.getKey().longValue() - prevStep ;
79 시도해 보세요{
80System.out.println("** 기다리고 있습니다"+ diffInSeconds * 1000+"밀리초");
81w.join( diffInSeconds * 1000 );
82}잡기( 예외 e )
83System.out.println("** 예외가 발생했습니다: "+e);
84 휴식;
85}
86
87prevStep = Entry.getKey().longValue();
88 시도해 보세요{
89파일 로그파일 =신규파일(ws.workingDirectory(), "cplex.op2");
90BufferedWriter 아웃파일 =신규버퍼링라이터(신규파일 작성기(로그파일));
91outfile.write(entry.getValue()); outfile.newLine();
92outfile.close();
93}잡기(예외 e)
94e.printStackTrace();
95System.exit(1);
96}
97직업.인터럽트();
98System.out.println("** 새 옵션을 계속하기 위해 Cplex가 중단되었습니다: "+ Entry.getValue());
99}
100 if(w.isAlive())
101 시도{
102w.join();
103}잡기(InterruptedException e)
104}
105
106문자열 로그 = os.toString();
107 if(!log.contains("중단되었습니다...")) {
108System.out.println("** 솔버 로그 **");
109System.out.println(로그);
110System.out.println();
111System.out.println("** 솔버가 적어도 한 번은 중단될 것으로 예상됩니다.");
112System.exit(1);
113}
114System.out.println("** 중단되었습니다...");
115System.exit(0);
116}
117
119 정적 클래스노동자확장스레드
120 GAMSJob직업;
121PrintStream 출력;
122GAMSOptions 옵션;
123
129 공개노동자(GAMSJobjb, GAMSOptions 선택, PrintStream 출력)
130직업 = jb;
131옵션 = 선택;
132출력 = 출력;
133}
134
137 공개 공허실행()던지기 슬롯 게임예외{
138직업.실행(옵션, 출력);
139}
140}
141}
void setSystemDirectory(문자열 디렉터리)
void setWorkingDirectory(문자열 디렉터리)
GAMSJob addJobFromGamsLib(문자열 모델 이름)
이 예는 ...을 사용하여 어려운 MIP에 대한 복잡한 종료 기준을 구현하는 방법을 보여줍니다.