Заключение
В результате проделанной работы, для выбранной проблемной области была поставлена и решена открытая задача выбора архитектуры кластерной вычислительной системы, с применением решателя открытых задач.
В ходе курсового проекта разработан блок качественной оценки выдвигаемых гипотез решателя открытых задач. Важной особенностью работы является реализация интерфейса решатель – блок качественной оценки.
Был проведен эксперимент, который доказывает возможность правильного обучения решателя на заданную проблемную область.
Литература
Методические указания к выполнению лабораторных работ по курсу «Вычислительные системы» Ладыгин И.И.
Учебно - Информационный Портал, технологии и протоколы связи
http://www.connect-portal.info/pr_gb_ethernet%20.html
«AMD» – продукты и технологии
http://www.amd.com/RU/PRODUCTS/Pages/Products.aspx
«Intel» – серверная продукция
http://www.intel.ru/content/www/ru/ru/servers/server-products.html
«IBM» – серверные продукты
http://www-03.ibm.com/systems/ru/
Магазин комплектующих «Intel»
http://ark.intel.com/products/series/53495
«Server-Unit» – серверное оборудование любого уровня (магазин)
http://www.server-unit.ru/
«Team-computers» – производитель компьютерной техники
http://www.team.ru/server/serv_main_business.php
Методическое пособие «Применение решателя открытых задач»
Дзегеленок И.И., Кондратьев М.А. Аляева Ю.В. — М.: Изд-во МЭИ, 2012. — 49 c.
Приложение а
Техническое задание
Приложение б
Листинг программы блока качественной оценки
library BKO;
{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }
uses
SysUtils,
Classes,
BKOExportUnit in 'BKOExportUnit.pas',
BKOMainForm in 'BKOMainForm.pas' {fmBKOMain},
BKOOptionsForm in 'BKOOptionsForm.pas' {fmBKOOptions},
slClasses in 'units\slClasses.pas',
slConst in 'units\slConst.pas',
slFunction in 'units\slFunction.pas',
slLibs in 'units\slLibs.pas',
slNetTypes in 'units\slNetTypes.pas',
slTypes in 'units\slTypes.pas';
{$R *.res}
exports
GetRateModuleFunc name 'GetRateModuleFunc', //экспортируемая оценочная функция
GetRateModuleForm name 'GetRateModuleForm'; //Экспортируемая функция настройки системы
begin
end.
unit BKOMainForm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, slConst, slClasses, slLibs, StdCtrls, ComCtrls;
type
TfmBKOMain = class(TForm)
lvSolverHipothesis: TListView;
pnLeft: TPanel;
btnAppreciate: TButton;
rgAppreciate: TRadioGroup;
pnBottom: TPanel;
ButtonPanel: TPanel;
btnOK: TButton;
btnCancel: TButton;
Good: TLabel;
Bad: TLabel;
GoodCount: TLabel;
BadCount: TLabel;
ApCount: TLabel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
procedure rgAppreciateClick(Sender: TObject);
procedure lvSolverHipothesisClick(Sender: TObject);
procedure btnAppreciateClick(Sender: TObject);
procedure lvSolverHipothesisCustomDrawItem(Sender: TCustomListView;
Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
private
FSolverBase: TSolverBase;
FRateFuncInfo: rRateFuncInfo;
procedure MarkHipothesisForAppreciate;
function AppreciateHipothesis(ASolverBase: TSolverBase): boolean;
function MarkedHipothesisCount: integer;
public
property HipSolverBase: TSolverBase read FSolverBase write FSolverBase;
function GetRateFuncInfo: rRateFuncInfo;
constructor Create(AOwner: TComponent; var ASolverBase: TSolverBase); reintroduce; overload;
end;
implementation
{$R *.dfm}
{ TfmBKOMain }
//Функция оценки гипотез
function TfmBKOMain.AppreciateHipothesis(ASolverBase: TSolverBase): boolean;
var
i,nS,nUS: integer;
proc, freq, nump, nodes, net, os, ram, rom, task : string;
NoBadComb, criter, light, medium, hard : boolean;
begin
with lvSolverHipothesis do begin
Items.BeginUpdate;
//Обнуляем число оцененных гипотез
FRateFuncInfo.iSuccess:=0;
FRateFuncInfo.iUnSuccess:=0;
//и счетчики противоречий и подтверждений
nS:=0; nUS:=0;
try
//Начинаем проверку списка гипотез
for i := 0 to Items.Count - 1 do
if Items[i].Checked then begin
proc := Items[i].SubItems.ValueFromIndex[1]; // Марка процессора
freq := Items[i].SubItems.ValueFromIndex[2]; //Частота процессора
nump := Items[i].SubItems.ValueFromIndex[3]; //Кол-во процессоров
nodes := Items[i].SubItems.ValueFromIndex[4]; //Кол-во узлов
net := Items[i].SubItems.ValueFromIndex[5]; //Сеть
os := Items[i].SubItems.ValueFromIndex[6]; //Операционная система
ram := Items[i].SubItems.ValueFromIndex[7]; //Емкость опер. памяти
rom := Items[i].SubItems.ValueFromIndex[8]; //Емкость жесткого диска
task := Items[i].SubItems.ValueFromIndex[9]; //Связность задач
//ShowMessage(task);
//Проверяем наличие запрещенных комбинаций
if ( (proc = 'Intel Itanium 2') and (freq = '1.7GHz') ) or
( (proc = 'Intel Itanium 2') and (freq = '1.8GHz') ) or
( (proc = 'Intel Itanium 2') and (freq = '2.0GHz') ) or
( (proc = 'Intel Itanium 2') and (freq = '2.2GHz') ) or
( (proc = 'Intel Itanium 2') and (freq = '2.4GHz') ) or
( (proc = 'Intel Itanium 2') and (freq = '2.6GHz') ) or
( (proc = 'Intel Itanium 2') and (freq = '2.66GHz') ) or
( (proc = 'Intel Itanium 2') and (freq = '2.8GHz') ) or
( (proc = 'Intel Itanium 2') and (freq = '3.06GHz') ) or
( (proc = 'Intel Itanium 2') and (freq = '3.2GHz') ) or
( (proc = 'Intel Itanium 2') and (freq = '3.4GHz') ) or
( (proc = 'AMD Opteron') and (freq = '1.2GHz') ) or
( (proc = 'AMD Opteron') and (freq = '1.7GHz') ) or
( (proc = 'AMD Opteron') and (freq = '2.6GHz') ) or
( (proc = 'AMD Opteron') and (freq = '2.66GHz') ) or
( (proc = 'AMD Opteron') and (freq = '2.8GHz') ) or
( (proc = 'AMD Opteron') and (freq = '3.06GHz') ) or
( (proc = 'AMD Opteron') and (freq = '3.2GHz') ) or
( (proc = 'AMD Opteron') and (freq = '3.4GHz') ) or
( (proc = 'AMD Athlon') and (freq = '3.06GHz') ) or
( (proc = 'AMD Athlon') and (freq = '3.2GHz') ) or
( (proc = 'AMD Athlon') and (freq = '3.4GHz') )
then NoBadComb := false //запрещенные комбинации есть
else NoBadComb := true; //запрещенных комбинаций нет
//Проверка по критериям стоимости и производительности КВС
if (not(freq = '1.2GHz') and not(freq = '1.3GHz')) and
(not(nump = '1')) and
(not(nodes = '4') and not(nodes = '4000') and not(nodes = '5000')) and
(not(ram = '4GB')) and
(not(rom = '20GB') and not(rom = '2000GB'))
then criter := true
else criter := false;
//Проверка КВС на соответствие СЛАБОсвязанному классу задач
if (task = 'Слабосвязанные') and
((net = 'Fast Ethernet') or (net = 'Myrinet') or (net = 'SCI') or (net = 'cLAN')) and
((ram = '12GB') or (ram = '24GB') or (ram = '48GB'))
then light := true
else light := false;
//Проверка КВС на соответствие СРЕДНЕсвязанному классу задач
if (task = 'Среднесвязанные') and
((net = 'Myrinet') or (net = 'SCI') or (net = 'cLAN') or (net = 'Gigabit Ethernet')) and
((ram = '12GB') or (ram = '24GB') or (ram = '48GB') or (ram = '64GB'))
then medium := true
else medium := false;
//Проверка КВС на соответствие СИЛЬНОсвязанному классу задач
if (task = 'Сильносвязанные') and
((net = 'cLAN') or (net = 'Gigabit Ethernet') or (net = 'QsNetII') or (net = 'Infiniband')) and
((ram = '24GB') or (ram = '48GB') or (ram = '64GB') or (ram = '96GB'))
then hard := true
else hard := false;
//Если гипотеза удовлетворяет необходимым условиям, то считаем её положительной
if (NoBadComb = true) and (criter = true) and ((light = true) or (medium = true) or (hard = true))
then begin
//В зависимости от веса гипотезы и ее оценки БКО обрабатываем счетчики
//противоречий и подтверждений
if (TSolverObject(Items[i].Data).ObjectWeight < 0) then
nUS:=nUS+1
else
nS:=nS+1;
//Меняем наименование
TSolverObject(Items[i].Data).ObjectName := Format('Авт.Оцен.Гип#%d.Уд', [i]);
//Говорим что эта гипотеза будет фактом
TSolverObject(Items[i].Data).ObjectClass := ocFact;
//Причем удачным
TSolverObject(Items[i].Data).ObjectType := sotSuccess;
//Увеличиваем счетчик положительных гипотез
Inc(FRateFuncInfo.iSuccess);
end
//Если гипотеза не проходит по параметрам, то считаем её отрицательной
else begin
//В зависимости от веса гипотезы и ее оценки БКО обрабатываем счетчики
//противоречий и подтверждений
if (TSolverObject(Items[i].Data).ObjectWeight < 0) then
nS:=nS+1
else
nUS:=nUS+1;
//Меняем наименование
TSolverObject(Items[i].Data).ObjectName := Format('Авт.Оцен.Гип#%d.Неуд', [i]);
//Говорим что эта гипотеза будет фактом
TSolverObject(Items[i].Data).ObjectClass := ocFact;
//Причем неудачным
TSolverObject(Items[i].Data).ObjectType := sotUnSuccess;
//Увеличиваем счетчик отрицательных гипотез
Inc(FRateFuncInfo.iUnSuccess);
end
end;
finally
Items.EndUpdate;
end;
//Вывод счетчиков подтверждений и противоречий
Label1.Caption := IntToStr (nS);
Label3.Enabled := true;
Label2.Caption := IntToStr (nUS);
Label4.Enabled := true;
//Выводим число оцененных гипотез
GoodCount.Caption := IntToStr(FRateFuncInfo.iSuccess);
GoodCount.Visible := true;
BadCount.Caption := IntToStr(FRateFuncInfo.iUnSuccess);
BadCount.Visible := true;
//Показываем надписи
ApCount.Enabled := true;
Bad.Enabled := true;
Good.Enabled := true;
end;
Result := True;
end;
{*----------------------------------------------------------------------------
Конструктор для создания формы
Параметры конструктора:
AOwner: TComponent; - обьект-владелец для формы
var ASolverBase: TSolverBase; - База РОЗ
----------------------------------------------------------------------------*}
constructor TfmBKOMain.Create(AOwner: TComponent; var ASolverBase: TSolverBase);
var
i, j: integer;
begin
inherited Create(AOwner); //Вызов конструктора в родителе
FSolverBase := ASolverBase;
with FRateFuncInfo do begin //Начальные установки
iSuccess := 0;
iUnsuccess := 0;
end;
//Заполенение листа гипотез
with lvSolverHipothesis, FSolverBase do begin
Items.BeginUpdate;
try
{1. Заполним список параметров}
for i := 0 to ParamList.Count - 1 do
with Columns.Add do Caption := ParamList.Param[i].ParamName;
{2. заполним список гипотез}
for i := 0 to ObjectList.Count - 1 do
if ObjectList.Objects[i].ObjectClass in [ocHipothesis] then //!!Обязательно только гипотезы!!
with Items.Add do begin
Caption := ObjectList.Objects[i].ObjectName;
{3. для каждой гипотезы заполним список параметров}
SubItems.Add(FloatToStr(ObjectList.Objects[i].ObjectWeight));
for j := 0 to ParamList.Count - 1 do
SubItems.Add(' '+ParamList.Param[j].ValueByID[ObjectList.Objects[i].ParamById(ParamList.Param[j].ParamID).fValueID]);
Data := pointer(ObjectList.Objects[i]);
end;
Selected := TopItem;
ItemFocused := Selected;
finally
Items.EndUpdate;
end;
end;
rgAppreciateClick(rgAppreciate);
//rgCrit.ItemIndex:=0;
end;
{*----------------------------------------------------------------------------
Функция подсчета гипотез(сделана только для примера) подсчитывает кол-во
помеченных на оценку гипотез в lvSolverHipothesis
----------------------------------------------------------------------------*}
function TfmBKOMain.MarkedHipothesisCount: integer;
var
i: integer;
begin
Result := 0;
with lvSolverHipothesis do
for i := 0 to Items.Count - 1 do if Items[i].Checked then Inc(Result);
end;
{*----------------------------------------------------------------------------
Помечание обьектов для оценки в lvSolverHipothesis в соответсвии с выделенным
пунктом меню
----------------------------------------------------------------------------*}
procedure TfmBKOMain.MarkHipothesisForAppreciate;
var
i: integer;
_maxWeight, _minWeight: Integer;
begin
with lvSolverHipothesis do begin
Items.BeginUpdate;
try
case rgAppreciate.ItemIndex of
0: for i := 0 to Items.Count - 1 do Items[i].Checked := True; //все
1: begin //макс-мин
_maxWeight := TSolverObject(Items[0].Data).ObjectWeight;
_minWeight := TSolverObject(Items[0].Data).ObjectWeight;
for i := 1 to Items.Count - 1 do begin
if TSolverObject(Items[i].Data).ObjectWeight > _maxWeight then _maxWeight := TSolverObject(Items[i].Data).ObjectWeight;
if TSolverObject(Items[i].Data).ObjectWeight < _minWeight then _minWeight := TSolverObject(Items[i].Data).ObjectWeight;
end;
for i := 1 to Items.Count - 1 do
Items[i].Checked := (TSolverObject(Items[i].Data).ObjectWeight = _minWeight) or (TSolverObject(Items[i].Data).ObjectWeight = _maxWeight);
end;
2: for i := 0 to Items.Count - 1 do Items[i].Checked := False; //по выбору
end;
finally
Items.EndUpdate;
end;
end;
end;
{*----------------------------------------------------------------------------
Щелчек мышкой по RadioGroup
----------------------------------------------------------------------------*}
procedure TfmBKOMain.rgAppreciateClick(Sender: TObject);
begin
with (Sender as TRadioGroup) do
lvSolverHipothesis.Checkboxes := (ItemIndex = 2);
MarkHipothesisForAppreciate;
btnAppreciate.Enabled := (MarkedHipothesisCount <> 0);
end;
{*----------------------------------------------------------------------------
Щелчек мышкой по ListView
----------------------------------------------------------------------------*}
procedure TfmBKOMain.lvSolverHipothesisClick(Sender: TObject);
begin
with TListView(Sender) do Selected := ItemFocused;
btnAppreciate.Enabled := (MarkedHipothesisCount <> 0);
end;
{*----------------------------------------------------------------------------
Щелчек мышкой по кнопочке "Оценить"
----------------------------------------------------------------------------*}
procedure TfmBKOMain.btnAppreciateClick(Sender: TObject);
begin
AppreciateHipothesis(FSolverBase);
end;
{*----------------------------------------------------------------------------
Отрисовка строчки в lvSolverHipothesis цветом в соответсвии с разметкой
удачный\неудачный\никакой
----------------------------------------------------------------------------*}
procedure TfmBKOMain.lvSolverHipothesisCustomDrawItem(Sender: TCustomListView; Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
var
_Brush: TBrush;
begin
with (Sender as TListView).Canvas do begin
_Brush := Brush; //сохраняем текущее состоянии кисти
try
if Item.Data <> nil then begin //в Data обьекта-строчки что-ниить записано?
with TSolverObject(Item.Data) do
if ObjectClass = ocFact then begin //Если то что там записано уже стал фактом то
case ObjectType of //в зависимости от типа пометить цветом
sotSuccess: Brush.Color := _scvSuccessFact;
sotUnsuccess: Brush.Color := _scvUnSuccessFact;
sotIndefinite: Brush.Color := _scvIndefiniteFact;
sotNone: Brush.Color := _scvHipothesis;
end;
FillRect(Item.DisplayRect(drLabel)); //отрисовать этот цвет
end;
end;
finally
Brush := _Brush; //Вернуть на место кисть
end;
end;
end;
{*----------------------------------------------------------------------------
Возвращает значение вовне
----------------------------------------------------------------------------*}
function TfmBKOMain.GetRateFuncInfo: rRateFuncInfo;
begin
Result := FRateFuncInfo; //
end;
end.