로드 중...
검색 중...
일치하는 항목 없음
Form1.cs
1사용 중시스템;
2사용 중System.Collections.Generic;
3사용 중System.ComponentModel;
4사용 중시스템.데이터;
5사용 중시스템.드로잉;
6사용 중System.Linq;
7사용 중시스템.텍스트;
8사용 중System.Windows.Forms;
9사용 중슬롯 나라;
10사용 중System.Windows.Forms.DataVisualization.Charting;
11사용 중시스템.진단;
12사용 중System.Data.OleDb;
13사용 중시스템.반사;
14
15네임스페이스Demo1GUI
16{
22 공개 부분 수업양식1: 양식
23{
24
25 비공개문자열[] 마침표 =신규문자열[]"얀", "2월", "마르", "4월", "5월", "준", "7월", "8월", "9월", "10월", "11월", "12월"};
26 비공개사전<튜플<문자열, 문자열>,더블> landreq =신규사전<Tuple<문자열, 문자열>,더블>()
27{
28{신규튜플<문자열,문자열> ("밀", "얀"), 1 },
29{신규튜플<문자열,문자열> ("밀", "2월"), 1 },
30{신규튜플<문자열,문자열> ("밀", "마르"), 1 },
31{신규튜플<문자열,문자열> ("밀", "4월"), 1 },
32{신규튜플<문자열,문자열> ("밀", "5월"), 1 },
33{신규튜플<문자열,문자열> ("밀", "11월"), 0.5 },
34{신규튜플<문자열,문자열> ("밀", "12월"), 1 },
35
36{신규튜플<문자열,문자열> ("클로버", "얀"), 1 },
37{신규튜플<문자열,문자열> ("클로버", "2월"), 1 },
38{신규튜플<문자열,문자열> ("클로버", "마르"), 0.5 },
39{신규튜플<문자열,문자열> ("클로버", "11월"), 0.25 },
40{신규튜플<문자열,문자열> ("클로버", "12월"), 1 },
41
42{신규튜플<문자열,문자열> ("콩", "얀"), 1 },
43{신규튜플<문자열,문자열> ("콩", "2월"), 1 },
44{신규튜플<문자열,문자열> ("콩", "마르"), 1 },
45{신규튜플<문자열,문자열> ("콩", "4월"), 1 },
46{신규튜플<문자열,문자열> ("콩", "11월"), 0.25 },
47{신규튜플<문자열,문자열> ("콩", "12월"), 1 },
48
49{신규튜플<문자열,문자열> ("양파", "얀"), 1 },
50{신규튜플<문자열,문자열> ("양파", "2월"), 1 },
51{신규튜플<문자열,문자열> ("양파", "마르"), 1 },
52{신규튜플<문자열,문자열> ("양파", "4월"), 1 },
53{신규튜플<문자열,문자열> ("양파", "5월"), 0.25 },
54{신규튜플<문자열,문자열> ("양파", "11월"), 0.5 },
55{신규튜플<문자열,문자열> ("양파", "12월"), 1 },
56
57{신규튜플<문자열,문자열> ("면", "마르"), 0.5 },
58{신규튜플<문자열,문자열> ("면", "4월"), 1 },
59{신규튜플<문자열,문자열> ("면", "5월"), 1 },
60{신규튜플<문자열,문자열> ("면", "준"), 1 },
61{신규튜플<문자열,문자열> ("면", "7월"), 1 },
62{신규튜플<문자열,문자열> ("면", "8월"), 1 },
63{신규튜플<문자열,문자열> ("면", "9월"), 1 },
64{신규튜플<문자열,문자열> ("면", "10월"), 1 },
65{신규튜플<문자열,문자열> ("면", "11월"), 0.75 },
66
67{신규튜플<문자열,문자열> ("옥수수", "5월"), 0.25 },
68{신규튜플<문자열,문자열> ("옥수수", "준"), 1 },
69{신규튜플<문자열,문자열> ("옥수수", "7월"), 1 },
70{신규튜플<문자열,문자열> ("옥수수", "8월"), 1 },
71{신규튜플<문자열,문자열> ("옥수수", "9월"), 1 },
72{신규튜플<문자열,문자열> ("옥수수", "10월"), 0.5 },
73
74{신규튜플<문자열,문자열> ("토마토", "7월"), 0.75 },
75{신규튜플<문자열,문자열> ("토마토", "8월"), 1 },
76{신규튜플<문자열,문자열> ("토마토", "9월"), 1 },
77{신규튜플<문자열,문자열> ("토마토", "10월"), 1 },
78{신규튜플<문자열,문자열> ("토마토", "11월"), 0.75 }
79};
80
81 비공개사전<Tuple<문자열, 문자열>,더블> 노동요구 =신규사전<Tuple<문자열, 문자열>,더블>()
82{
83{신규튜플<문자열,문자열> ("밀", "얀"), 1.72 },
84{신규튜플<문자열,문자열> ("밀", "2월"), 0.5 },
85{신규튜플<문자열,문자열> ("밀", "마르"), 1 },
86{신규튜플<문자열,문자열> ("밀", "4월"), 1 },
87{신규튜플<문자열,문자열> ("밀", "5월"), 17.16 },
88{신규튜플<문자열,문자열> ("밀", "준"), 2.34 },
89{신규튜플<문자열,문자열> ("밀", "11월"), 2.43 },
90{신규튜플<문자열,문자열> ("밀", "12월"), 1.35 },
91
92{신규튜플<문자열,문자열> ("클로버", "얀"), 4.5 },
93{신규튜플<문자열,문자열> ("클로버", "2월"), 1 },
94{신규튜플<문자열,문자열> ("클로버", "마르"), 8 },
95{신규튜플<문자열,문자열> ("클로버", "11월"), 2.5 },
96{신규튜플<문자열,문자열> ("클로버", "12월"), 7.5 },
97
98{신규튜플<문자열,문자열> ("콩", "얀"), 0.75 },
99{신규튜플<문자열,문자열> ("콩", "2월"), 0.75 },
100{신규튜플<문자열,문자열> ("콩", "마르"), 0.75 },
101{신규튜플<문자열,문자열> ("콩", "4월"), 16 },
102{신규튜플<문자열,문자열> ("콩", "11월"), 7.5 },
103{신규튜플<문자열,문자열> ("콩", "12월"), 0.75 },
104
105{신규튜플<문자열,문자열> ("양파", "얀"), 5.16 },
106{신규튜플<문자열,문자열> ("양파", "2월"), 5 },
107{신규튜플<문자열,문자열> ("양파", "마르"), 5 },
108{신규튜플<문자열,문자열> ("양파", "4월"), 19.58 },
109{신규튜플<문자열,문자열> ("양파", "5월"), 2.42 },
110{신규튜플<문자열,문자열> ("양파", "11월"), 11.16 },
111{신규튜플<문자열,문자열> ("양파", "12월"), 4.68 },
112
113{신규튜플<문자열,문자열> ("면", "마르"), 5 },
114{신규튜플<문자열,문자열> ("면", "4월"), 5 },
115{신규튜플<문자열,문자열> ("면", "5월"), 9 },
116{신규튜플<문자열,문자열> ("면", "준"), 2 },
117{신규튜플<문자열,문자열> ("면", "7월"), 1.5 },
118{신규튜플<문자열,문자열> ("면", "8월"), 2 },
119{신규튜플<문자열,문자열> ("면", "9월"), 1 },
120{신규튜플<문자열,문자열> ("면", "10월"), 26 },
121{신규튜플<문자열,문자열> ("면", "11월"), 12 },
122
123{신규튜플<문자열,문자열> ("옥수수", "5월"), 4.3 },
124{신규튜플<문자열,문자열> ("옥수수", "준"), 5.04 },
125{신규튜플<문자열,문자열> ("옥수수", "7월"), 7.16 },
126{신규튜플<문자열,문자열> ("옥수수", "8월"), 7.97 },
127{신규튜플<문자열,문자열> ("옥수수", "9월"), 4.41 },
128{신규튜플<문자열,문자열> ("옥수수", "10월"), 1.12 },
129
130{신규튜플<문자열,문자열> ("토마토", "7월"), 17 },
131{신규튜플<문자열,문자열> ("토마토", "8월"), 15 },
132{신규튜플<문자열,문자열> ("토마토", "9월"), 12 },
133{신규튜플<문자열,문자열> ("토마토", "10월"), 7 },
134{신규튜플<문자열,문자열> ("토마토", "11월"), 6 }
135};
136
137 비공개사전<문자열, 이중> 수율 =신규사전<문자열, 더블>()
138{
139{"밀", 1.5 },
140{"클로버", 6.5},
141{"콩", 1 },
142{"양파", 3 },
143{"면", 1.5 },
144{"옥수수", 2 },
145{"토마토", 3 }
146};
147
148 비공개사전<문자열, 이중> 가격 =신규사전<문자열, 더블>()
149{
150{"밀", 100 },
151{"콩", 200 },
152{"양파", 125 },
153{"면", 350 },
154{"옥수수", 70 },
155{"토마토", 120 }
156};
157
158 비공개Dictionary<String, double> miscost =신규사전<문자열, 더블>()
159{
160{"밀", 10 },
161{"콩", 5 },
162{"양파", 50 },
163{"면", 80 },
164{"옥수수", 5 },
165{"토마토", 50 }
166};
167
168 비공개 더블땅 = 4;
169 비공개 더블과세 = 3;
170 비공개 더블트와이지 = 4;
171
172 공개 양식1()
173{
174InitializeComponent();
175
176 // 기간에 대한 기본 행 추가
177 foreach(문자열 pin마침표)
178{
179this.dataGridLandReq.Rows.Add();
180this.dataGridLaborReq.Rows.Add();
181this.dataGridLandReq.Rows[this.dataGridLandReq.Rows.Count - 1].HeaderCell.Value = p;
182this.dataGridLaborReq.Rows[this.dataGridLaborReq.Rows.Count - 1].HeaderCell.Value = p;
183}
184
185 // 수율, 가격 및 비용에 대한 기본 행 추가
186this.dataGridYPM.Rows.Add(3);
187this.dataGridYPM.Rows[0].HeaderCell.Value ="수익률";
188this.dataGridYPM.Rows[0].HeaderCell.ToolTipText ="작물 수확량(ha당 톤)";
189this.dataGridYPM.Rows[1].HeaderCell.Value ="가격";
190this.dataGridYPM.Rows[1].HeaderCell.ToolTipText ="곡물 가격 (톤당 $)";
191this.dataGridYPM.Rows[2].HeaderCell.Value ="잘못된 비용";
192this.dataGridYPM.Rows[2].HeaderCell.ToolTipText ="기타 현금 비용(ha당 $)";
193
194 // 토지 요구 사항 데이터 바인딩
195 foreach(KeyValuePair<Tuple<문자열, 문자열>,더블> kvlandreq)
196{
197 foreach(DataGridViewRow rinthis.dataGridLandReq.Rows)
198 if(kv.Key.Item2.Equals(r.HeaderCell.Value))
199{
200r.Cells[kv.Key.Item1 +"_land"].값 = kv.값;
201 휴식;
202}
203}
204
205 // 노동 요구 사항 데이터 결합
206 foreach(KeyValuePair<Tuple<문자열, 문자열>,더블> kvin노동요구)
207{
208 foreach(DataGridViewRow rinthis.dataGridLaborReq.Rows)
209 if(kv.Key.Item2.Equals(r.HeaderCell.Value))
210{
211r.Cells[kv.Key.Item1 +"_lab"].값 = kv.값;
212 휴식;
213}
214}
215
216 // 결합 수익률, 가격, 비용
217 foreach(DataGridViewRow rinthis.dataGridYPM.Rows)
218{
219 if ("수익률".Equals(r.HeaderCell.Value))
220{
221 foreach(KeyValuePair<String, double> kvin수율)
222r.Cells[kv.Key +"_ypm"].값 = kv.값;
223}
224 그밖에 if ("가격".Equals(r.HeaderCell.Value))
225{
226 foreach(KeyValuePair<문자열, 더블> kv가격)
227r.Cells[kv.Key +"_ypm"].값 = kv.값;
228}
229 그밖에 if ("잘못된 비용".Equals(r.HeaderCell.Value))
230{
231 foreach(KeyValuePair<String, double> kvin불가)
232r.Cells[kv.Key +"_ypm"].값 = kv.값;
233}
234}
235
236 // 스칼라 바인딩
237this.textBoxLand.Text = this.land.ToString();
238this.textBoxOwage.Text = this.owage.ToString();
239this.textBoxTwage.Text = this.twage.ToString();
240
241 // 결과 테이블 준비
242this.dataGridCR.Rows.Add(3);
243this.dataGridCR.Rows[0].HeaderCell.Value ="토지 이용";
244this.dataGridCR.Rows[1].HeaderCell.Value ="출력";
245this.dataGridCR.Rows[2].HeaderCell.Value ="수익";
246
247this.dataGridViewLRS.Rows.Add(13);
248 for (inti = 0; i < 마침표.길이; 나++)
249this.dataGridViewLRS.Rows[i].HeaderCell.Value = 마침표[i];
250this.dataGridViewLRS.Rows[12].HeaderCell.Value ="전체";
251
252}
253
254 비공개 공허button1_Click_1(객체발신자, EventArgs e)
255{
256this.button1.Enabled =거짓;
257
258this.chart1.Series.Clear();
259this.chart1.ResetAutoValues();
260this.chart1.Visible =;
261시리즈 s = this.chart1.Series.Add("토지 이용");
262s.ChartType = SeriesChartType.Pie;
263s.BorderWidth = 1;
264s["PieLabelStyle"] ="외부";
265s.라벨 ="#VALX (#PERCENT)";
266this.chart1.ChartAreas[0].Area3DStyle.Enable3D =;
267this.chart1.Legends[0].Enabled =거짓;
268
269this.chart2.Series.Clear();
270this.chart2.ResetAutoValues();
271this.chart2.Visible =;
272this.chart2.Series.Add("totlanduse").ChartType = SeriesChartType.Column;
273this.chart2.ChartAreas[0].Area3DStyle.Enable3D =;
274this.chart2.ChartAreas[0].AxisX.Interval = 1;
275this.chart2.ChartAreas[0].AxisY.Title ="하";
276this.chart2.ChartAreas[0].AxisY.TextOrientation = TextOrientation.Horizontal;
277
279
280 // 사용자 입력에서 데이터 가져오기
282
283 GAMSSett = 데이터.추가세트("t", 1,"기간");
284 foreach(문자열 p마침표)
285t.AddRecord(p);
286
287
288 슬롯 나라매개변수landreq = data.AddParameter("landreq", 2,"작물별 토지 점유 기간(헥타르)");
289 foreach(DataGridViewRow 행inthis.dataGridLandReq.Rows)
290{
291문자열 기간 = (String)row.HeaderCell.Value;
292 for (inti = 0; i < 행.Cells.Count; 나++)
293 if(row.Cells[i].값 !=&& !row.Cells[i].Value.Equals(""))
294landreq.AddRecord(기간, this.dataGridLandReq.Columns[i].HeaderText).Value = Convert.ToDouble(row.Cells[i].Value);
295}
296
297 슬롯 나라매개변수laborreq = data.AddParameter("노동요구", 2,"작물 노동 요구량(헥타르당 노동일수)");
298 foreach(DataGridViewRow 행this.dataGridLaborReq.Rows)
299{
300문자열 기간 = (String)row.HeaderCell.Value;
301 for (inti = 0; i < 행.Cells.Count; 나++)
302 if(row.Cells[i].값 !=&& !row.Cells[i].Value.Equals(""))
303laborreq.AddRecord(기간, this.dataGridLaborReq.Columns[i].HeaderText).Value = Convert.ToDouble(row.Cells[i].Value);
304}
305
306 슬롯 나라매개변수수율 = data.AddParameter("수율", 1,"작물 수확량(헥타르당 톤)");
307 슬롯 나라매개변수가격 = data.AddParameter("가격", 1,"농작물 가격(톤당 달러)");
308 슬롯 나라매개변수miscost = data.AddParameter("잘못된 비용", 1,"기타 현금 비용(헥타르당 달러)");
309 foreach(DataGridViewRow 행inthis.dataGridYPM.Rows)
310{
311 for (inti = 0; i < 행.Cells.Count; 나++)
312 if(row.Cells[i].값 !=&& !row.Cells[i].Value.Equals(""))
313data.GetParameter(row.HeaderCell.Value.ToString()).AddRecord(this.dataGridYPM.Columns[i].HeaderCell.Value.ToString()).Value = Convert.ToDouble(row.Cells[i].Value);
314}
315
316data.AddParameter("땅", 0,"농장 규모(헥타르)").AddRecord().= Convert.ToDouble(this.textBoxLand.Text);
317data.AddParameter("부채", 0,"고용 임금률(일당 달러)").AddRecord().Value = Convert.ToDouble(this.textBoxOwage.Text);
318data.AddParameter("트웨이지", 0,"임시 노동 임금(일당 달러)").AddRecord().Value = Convert.ToDouble(this.textBoxTwage.Text);
319
320 // 슬롯 나라 작업 실행
321 슬롯 나라옵션opt = ws.AddOptions();
322선택.정의.추가("데이터", 데이터.이름);
323 GAMSJobj = ws.AddJobFromString(GetModelText());
324j.실행(선택, 데이터);
325
326 //일부 결과 표시
327 foreach (GAMSVariableRecordrecj.OutDB.GetVariable("xcrop"))
328 if(추천레벨> 0)
329this.chart1.Series["토지 이용"].Points.AddXY(rec.Key(0), Rec.레벨);
330
331사전<문자열, 이중> vals =신규사전<string, double>();
332 foreach(GAMSSetRecordrecinj.OutDB.GetSet("t"))
333vals.Add(rec.Key(0), 0);
334 foreach (GAMSParameterRecordrecinj.OutDB.GetParameter("전체 토지 사용"))
335vals[rec.Key(0)] = Rec.Value;
336 foreach(KeyValuePair<String, double> kvin발)
337this.chart2.Series["totlanduse"].Points.AddXY(kv.Key, kv.Value);
338
339ClearDataGridView(this.dataGridCR);
340 foreach (GAMSParameterRecordrecinj.OutDB.GetParameter("croprep"))
341SetCellValue(this.dataGridCR, rec.Key(0), rec.Key(1), rec.Value);
342
343ClearDataGridView(this.dataGridViewLRS);
344 foreach (GAMSParameterRecordrecinj.OutDB.GetParameter("labrep"))
345SetCellValue(this.dataGridViewLRS, rec.Key(0), rec.Key(1), rec.Value);
346
347this.chart1.Update();
348this.chart2.Update();
349this.label4.Text ="농장 수입 ($): "+ j.OutDB.GetVariable("yfarm").FindRecord().Level.ToString("0.####");
350
351this.button1.Enabled =;
352}
353
354 공개 공허SetCellValue(DataGridView dgv, 문자열 rowHeader, 문자열 colHeader,더블값)
355{
356 foreach(DataGridViewColumn 열dgv.열)
357{
358 if(col.HeaderText.Equals(colHeader))
359{
360 foreach(DataGridViewRow 행indgv.Rows)
361{
362 if(row.HeaderCell.Value.Equals(rowHeader))
363{
364row.Cells[col.Index].Value = 값;
365}
366}
367}
368}
369}
370
371 공개 공허ClearDataGridView(DataGridView dgv)
372{
373 for (inti = 0; i < dgv.Columns.Count; 나++)
374{
375 for (intj = 0; j < dgv.Rows.Count; j++)
376{
377dgv.Rows[j].Cells[i].Value ="";
378}
379}
380}
381
382 정적문자열 GetModelText()
383{
384문자열 모델 =@"
385c 작물 설정 / 밀, 클로버, 콩, 양파,
386목화, 옥수수, 토마토 /
387t 기간;
388
389$gdxin 데이터
390$load t
391$gdxin
392
393매개변수 landreq(t,c) 작물별 토지 점유 개월수(헥타르);
394매개변수 노동요구량(t,c) 작물 노동 요구사항(헥타르당 인력);
395
396$퇴출
397
398매개변수 수확량(c) 작물 수확량(헥타르당 톤)
399price(c) 작물 가격(톤당 달러)
400miscost(c) 기타 현금 비용(헥타르당 달러)
401
402* 농장 데이터, 규모 노동 가용성 등
403
404스칼라 토지 농장 규모(헥타르)
405famlab 가족 노동 가능(월당 일수) / 25 /
406임금 고용 임금률(일당 달러)
407임시노동 임금(일당 달러)
408dpm 월별 근무일 수 / 25 /
409
410$gdxin 데이터
411$load landreq Laborreq 토지 빚 과세 수익률 가격 불일치
412$gdxin
413
414$Stitle 내생 변수 및 방정식
415
416변수 xcrop(c) 자르기 활동(헥타르)
417yfarm 농장 소득(달러)
418생산 수익 가치(달러)
419mcost 기타 현금 비용(달러)
420실험실 인건비(달러)
421labearn 노동소득(달러)
422flab(t) 가족 노동 사용(일)
423fout(t) 고용(일)
424tlab(t) 임시 노동(일)
425
426양수 변수 xcrop, flab ,fout, tlab
427
428방정식 landbal(t) 토지 수지(헥타르)
429노동(t) 노동수지(일)
430flabor(t) 가족 노동수지(일)
431arev 수익 회계(달러)
432acost 현금 비용 회계(달러)
433alab 인건비 회계(달러)
434근로소득회계에 대하여(달러)
435소득 소득 정의(달러);
436
437
438landbal(t).. sum(c, xcrop(c)*landreq(t,c)) =l= 토지 ;
439
440laborbal(t).. sum(c, xcrop(c)*laborreq(t,c)) =l= flab(t) + tlab(t);
441
442flabor(t).. famlab =e= flab(t) + fout(t) ;
443
444arev.. 수익 =e= sum(c, xcrop(c)*yield(c)*price(c)) ;
445
446acost..mcost =e= sum(c, xcrop(c)*miscost(c)) ;
447
448alab.. labcost =e= sum(t, tlab(t)*twage) ;
449
450aout.. labearn =e= sum(t, fout(t)*owage) ;
451
452소득.. yfarm =e= 수익 + labearn - labcost - mcost ;
453
454
455모델 데모1 농장 노동 모델 / 모두 /
456
457yfarm을 최대화하는 lp를 사용하여 데모1을 해결하세요.
458
459$Stitle 솔루션 보고서
460
461크리프/토지 이용, 생산량, 수익 설정/
462lrep / 수요, 가족, 임시
463미사용, 임대 /
464
465매개변수 croprep 자르기 보고서 요약
466labrep 노동 보고서 요약(일);
467
468croprep('landuse',c) = xcrop.l(c);
469croprep('output',c) = xcrop.l(c)*yield(c);
470croprep('수익',c) = Croprep('출력',c)*가격(c);
471croprep(crep,'전체') = sum(c, Croprep(crep,c));
472
473labrep(t,'수요') = sum(c, xcrop.l(c)*laborreq(t,c));
474labrep(t,'패밀리') = flab.l(t);
475labrep(t,'임시') = tlab.l(t);
476labrep(t,'미사용') = -laborbal.l(t);
477labrep(t,'hire-out') = fout.l(t);
478labrep('total',lrep) = sum(t, labrep(t,lrep));
479
480매개변수 totalLandUse(t);
481totalLandUse(t) = sum(c, xcrop.l(c)*landreq(t,c))";
482
483 반환모델;
484}
485}
486}
이 농업 모델의 경우 입력 데이터를 여러 테이블에 직접 입력할 수 있습니다....
GAMSSet AddSet(문자열 식별자, 정수 차원, 문자열 설명텍스트="", SetType setType=SetType.multi)
void Run(GAMSOptions gamsOptions=null, GAMSCheckpoint 체크포인트=null, TextWriter 출력=null, Boolean createOutDB=true)
사전< 문자열, 문자열 > 정의
새 GAMSParameterRecord AddRecord(params 문자열[] 키)
새 GAMSSetRecord AddRecord(params 문자열[] 키)
GAMSDatabase AddDatabase(문자열 데이터베이스 이름=null, 문자열 inModelName=null)