diff --git a/readme.md b/readme.md index fb6963543..57b1d83f6 100644 --- a/readme.md +++ b/readme.md @@ -34,7 +34,7 @@ | 14 | [Макаревич Никита](https://github.com/sosiska52) |[ii02314](trunk/ii02314) | ✅ | ✅ | ✅ | ✅ | ✅ | | | | 7| | 15 | Маслакова Ксения | | ❌ | ❌ | ❌ | ❌ | | | | | | | 16 | [Медведь Павел](https://github.com/Dizzers) |[ii02316](trunk/ii02316) | ✅ | ✅ | ✅ | ✅ | ✅ | | | | 8| -| 17 | Новицкая Вероника |[ii02317](trunk/ii02317) | ✅ | ✅ | ❌ | ❌ | | | | | 6| +| 17 | Новицкая Вероника |[ii02317](trunk/ii02317) | ✅ | ✅ | ✅ | ❌ | ✅ | | | | 6| | 18 | Осипова Алла | | ❌ | ❌ | ❌ | ✅ | | | | | | | 19 | [Палто Елена](https://github.com/AlenaSokol) |[ii02319](trunk/ii02319) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | |(научная работа) 10| | 20 | [Романюк Алексей](https://github.com/Gomziakoff) |[ii02320](trunk/ii02320) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | 9| diff --git a/trunk/ii02320/task_02/doc/graph.png b/trunk/ii02317/task_02/doc/graph.png similarity index 100% rename from trunk/ii02320/task_02/doc/graph.png rename to trunk/ii02317/task_02/doc/graph.png diff --git a/trunk/ii02317/task_02/doc/readme.md b/trunk/ii02317/task_02/doc/readme.md new file mode 100644 index 000000000..26d2c6da9 --- /dev/null +++ b/trunk/ii02317/task_02/doc/readme.md @@ -0,0 +1,101 @@ +

Министерство образования Республики Беларусь

+

Учреждение образования

+

“Брестский Государственный технический университет”

+

Кафедра ИИТ

+
+

Лабораторная работа №2

+

По дисциплине “Общая теория интеллектуальных систем”

+

Тема: “ПИД-регуляторы”

+
+

Выполнил:

+

Студент 2 курса

+

Группы ИИ-23

+

Новицкая В.Д.

+

Проверил:

+

Иванюк Д. С.

+
+

Брест 2023

+ +--- + +# Общее задание # +1. Написать отчет по выполненной лабораторной работе №1 в .md формате (readme.md) и с помощью запроса на внесение изменений (**pull request**) разместить его в следующем каталоге: trunk\ii0xxyy\task_01\doc (где xx - номер группы, yy - номер студента, например **ii02102**). +2. Исходный код написанной программы разместить в каталоге: **trunk\ii0xxyy\task_01\src**. + + +# Выполнение задания # + +Код программы: + +#include +#include +#include +#include + +using namespace std; + +class PidRegulator { +private: + double K = 0.001; + double T = 100; + double Td = 100; + double h = 1; + + double q0 = K * (1 + Td / h); + double q1 = -K * (1 + 2 * Td / h - h / T); + double q2 = (K * Td) / h; + + vector q = {q0, q1, q2}; + vector e = {0, 0, 0}; + vector y = {0, 0, 0}; + vector u = {1, 1}; +public: + double sum() { + double sum = 0; + for (int i = 0; i < 3; i++) { + sum += q[i] * e[i]; + } + return sum; + } + void nline(int time, double setpoint, double a = 0.5, double b = 0.3, double c = 0.9, double d = 0.7) { + for (int i = 0; i < time; i++) { + e[0] = setpoint - y[y.size() - 1]; + e[1] = setpoint - y[y.size() - 2]; + e[2] = setpoint - y[y.size() - 3]; + u[0] = u[1] + sum(); + y.push_back(a * y[y.size() - 1] - b * y[y.size() - 2] * y[y.size() - 2] + c * u[0] + d * sin(u[1])); + u[1] = u[0]; + } + } + + vector getY() const{ + return y; + } +}; +int main() { + double value; + ofstream out("output.txt"); + PidRegulator f; + if (out.is_open()) { + cout << "Enter the value: "; + cin >> value; + f.nline(100, value); + vector y_value = f.getY(); + + for (int i = 0; i < y_value.size(); i++) { + double repValue = y_value[i] * value / y_value[y_value.size() - 1]; + cout << i << " " << repValue << endl; + out << i << " " << value << endl; + } + + out.close(); + } else { + cerr << "Error: Cannot open the output file." << std::endl; + } + return 0; +} + + + Линейный график и нелинейный графики: + + ![линейный график](graph.png) diff --git a/trunk/ii02317/task_02/src/CMakeLists.txt b/trunk/ii02317/task_02/src/CMakeLists.txt new file mode 100644 index 000000000..8fc092078 --- /dev/null +++ b/trunk/ii02317/task_02/src/CMakeLists.txt @@ -0,0 +1,21 @@ +# CMakeList.txt : CMake project for task_02, include source and define +# project specific logic here. +# +cmake_minimum_required (VERSION 3.8) + +# Enable Hot Reload for MSVC compilers if supported. +if (POLICY CMP0141) + cmake_policy(SET CMP0141 NEW) + set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$,$>,$<$:EditAndContinue>,$<$:ProgramDatabase>>") +endif() + +project ("otis2") + +# Add source to this project's executable. +add_executable (otis2 "otis2.cpp" ) + +if (CMAKE_VERSION VERSION_GREATER 3.12) + set_property(TARGET otis2 PROPERTY CXX_STANDARD 20) +endif() + +# TODO: Add tests and install targets if needed. diff --git a/trunk/ii02317/task_02/src/otis2.cpp b/trunk/ii02317/task_02/src/otis2.cpp new file mode 100644 index 000000000..f0fc77e2e --- /dev/null +++ b/trunk/ii02317/task_02/src/otis2.cpp @@ -0,0 +1,68 @@ +#include +#include +#include +#include + +using namespace std; + +class PidRegulator { +private: + double K = 0.001; + double T = 100; + double Td = 100; + double h = 1; + + double q0 = K * (1 + Td / h); + double q1 = -K * (1 + 2 * Td / h - h / T); + double q2 = (K * Td) / h; + + vector q = {q0, q1, q2}; + vector E = {0, 0, 0}; + vector y = {0, 0, 0}; + vector U = {1, 1}; +public: + double sum() { + double sum = 0; + for (int i = 0; i < 3; i++) { + sum += q[i] * E[i]; + } + return sum; + } + void nline(int Time, double Point, double a = 0.5, double b = 0.3, double c = 0.9, double d = 0.7) { + for (int i = 0; i < Time; i++) { + E[0] = Point - y[y.size() - 1]; //count E0 + E[1] = Point - y[y.size() - 2]; //count E1 + E[2] = Point - y[y.size() - 3]; //count E2 + U[0] = U[1] + sum(); //count U + y.push_back(a * y[y.size() - 1] - b * y[y.size() - 2] * y[y.size() - 2] + c * U[0] + d * sin(U[1])); + U[1] = U[0]; + } + } + vector getY() const{ + return y; + } +}; +int main() { + double value; + ofstream out("output.txt"); + PidRegulator f; + if (out.is_open()) { + cout << "Enter the value: "; + cin >> value; + f.nline(100, value); + vector y_value = f.getY(); + + for (int i = 0; i < y_value.size(); i++) { + double repValue = y_value[i] * value / y_value[y_value.size() - 1]; + cout << i << " " << repValue << endl; + out << i << " " << value << endl; + } + + out.close(); + } else { + cerr << "Error: Cannot open the output file." << std::endl; + } + return 0; +} + +