Skip to content
This repository has been archived by the owner on Dec 28, 2023. It is now read-only.

Commit

Permalink
Merge branch 'main' into task_05
Browse files Browse the repository at this point in the history
  • Loading branch information
VolkogonNikita authored Dec 27, 2023
2 parents 76e4f56 + 011d20f commit 337d7cf
Show file tree
Hide file tree
Showing 5 changed files with 191 additions and 1 deletion.
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
File renamed without changes
101 changes: 101 additions & 0 deletions trunk/ii02317/task_02/doc/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<p style="text-align: center;">Министерство образования Республики Беларусь</p>
<p style="text-align: center;">Учреждение образования</p>
<p style="text-align: center;">“Брестский Государственный технический университет”</p>
<p style="text-align: center;">Кафедра ИИТ</p>
<div style="margin-bottom: 10em;"></div>
<p style="text-align: center;">Лабораторная работа №2</p>
<p style="text-align: center;">По дисциплине “Общая теория интеллектуальных систем”</p>
<p style="text-align: center;">Тема: “ПИД-регуляторы”</p>
<div style="margin-bottom: 10em;"></div>
<p style="text-align: right;">Выполнил:</p>
<p style="text-align: right;">Студент 2 курса</p>
<p style="text-align: right;">Группы ИИ-23</p>
<p style="text-align: right;">Новицкая В.Д.</p>
<p style="text-align: right;">Проверил:</p>
<p style="text-align: right;">Иванюк Д. С.</p>
<div style="margin-bottom: 10em;"></div>
<p style="text-align: center;">Брест 2023</p>

---

# Общее задание #
1. Написать отчет по выполненной лабораторной работе №1 в .md формате (readme.md) и с помощью запроса на внесение изменений (**pull request**) разместить его в следующем каталоге: trunk\ii0xxyy\task_01\doc (где xx - номер группы, yy - номер студента, например **ii02102**).
2. Исходный код написанной программы разместить в каталоге: **trunk\ii0xxyy\task_01\src**.


# Выполнение задания #

Код программы:

#include <iostream>
#include <cmath>
#include <vector>
#include <fstream>

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<double> q = {q0, q1, q2};
vector<double> e = {0, 0, 0};
vector<double> y = {0, 0, 0};
vector<double> 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<double> 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<double> 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)
21 changes: 21 additions & 0 deletions trunk/ii02317/task_02/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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 "$<IF:$<AND:$<C_COMPILER_ID:MSVC>,$<CXX_COMPILER_ID:MSVC>>,$<$<CONFIG:Debug,RelWithDebInfo>:EditAndContinue>,$<$<CONFIG:Debug,RelWithDebInfo>: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.
68 changes: 68 additions & 0 deletions trunk/ii02317/task_02/src/otis2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#include <iostream>
#include <cmath>
#include <vector>
#include <fstream>

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<double> q = {q0, q1, q2};
vector<double> E = {0, 0, 0};
vector<double> y = {0, 0, 0};
vector<double> 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<double> 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<double> 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;
}


0 comments on commit 337d7cf

Please sign in to comment.