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

[task_01] Add solution #330

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
8 changes: 4 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@
| 7 | [Крупич Даниил](https://github.com/Duferig) | [ii02407](trunk/ii02407) | ✅ | ✅ | ✅ | ✅ | ✅ | | | | 8|
| 8 | Кураш Александр | [ii02408](trunk/ii02408) | ✅ | ✅ | ✅ | ✅ | ✅ | | | | 9|
| 9 | [Лозейко Максим](https://github.com/Maxim1-Lozeyko1)| [ii02409](trunk/ii02409) | ✅ | ❌ | ❌ | ❌ | ✅ | | | | 6|
| 10 | [Лящук Анастасия](https://github.com/anasosia) | [ii02410](trunk/ii02410) | ✅ | ❌ | ❌ | ❌ | ✅ | | | | 6|
| 11 | [Максимович Алина](https://github.com/vinberoj24) | [ii02411](trunk/ii02411) | ✅ | ✅ | ❌ | ❌ | ✅ | | | | 6|
| 12 | [Мшар Владислав](https://github.com/MsharVladislav)| [ii02412](trunk/ii02412) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | 9|
| 13 | Невдах Влидимир | [ii02413](trunk/ii02413) | | | ❌ | ❌ | | | | | |
dlinniy18 marked this conversation as resolved.
Show resolved Hide resolved
| 10 | Лящук Анастасия | [ii02410](trunk/ii02410) | ✅ | ❌ | ❌ | ❌ | ✅ | | | | 6|
| 11 | Максимович Алина | [ii02411](trunk/ii02411) | ✅ | ✅ | ❌ | ❌ | ✅ | | | | 6|
| 12 | Мшар Владислав | [ii02412](trunk/ii02412) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | 9|
| 13 | Невдах Влидимир | [ii02413](trunk/ii02413) | | | ❌ | ❌ | | | | | |
| 14 | [Поддубный Юрий](https://github.com/Yura-108) | [ii02414](trunk/ii02414) | ✅ | ✅ | ✅ | ✅ | ✅ | | | | 8|
| 15 | [Рекун Дмитрий](https://github.com/DmitryRekun) | [ii02415](trunk/ii02415) | ✅ | ✅ | ❌ | ❌ | ✅ | | | | 6|
| 16 | [Рудецкий Евгений](https://github.com/RuuuuuD3) | [ii02416](trunk/ii02416) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | | 9|
Expand Down
Binary file added trunk/ii02413/task_01/doc/picture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
151 changes: 151 additions & 0 deletions trunk/ii02413/task_01/doc/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
<p align="center"> Министерство образования Республики Беларусь</p>
<p align="center">Учреждение образования</p>
<p align="center">“Брестский Государственный технический университет”</p>
<p align="center">Кафедра ИИТ</p>
<br><br><br><br><br><br><br>
<p align="center">Лабораторная работа №1</p>
<p align="center">По дисциплине “Общая теория интеллектуальных систем”</p>
<p align="center">Тема: “Моделирования температуры объекта”</p>
<br><br><br><br><br>
<p align="right">Выполнил:</p>
<p align="right">Студент 2 курса</p>
<p align="right">Группы ИИ-24</p>
<p align="right">Невдах В.Р.</p>
<p align="right">Проверил:</p>
<p align="right">Иванюк Д. С.</p>
<br><br><br><br><br>
<p 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**.

## Task 1. Modeling controlled object ##
Let's get some object to be controlled. We want to control its temperature, which can be described by this differential equation:

$$\Large\frac{dy(\tau)}{d\tau}=\frac{u(\tau)}{C}+\frac{Y_0-y(\tau)}{RC} $$ (1)

where $\tau$ – time; $y(\tau)$ – input temperature; $u(\tau)$ – input warm; $Y_0$ – room temperature; $C,RC$ – some constants.

After transformation we get these linear (2) and nonlinear (3) models:

$$\Large y_{\tau+1}=ay_{\tau}+bu_{\tau}$$ (2)
$$\Large y_{\tau+1}=ay_{\tau}-by_{\tau-1}^2+cu_{\tau}+d\sin(u_{\tau-1})$$ (3)

where $\tau$ – time discrete moments ($1,2,3{\dots}n$); $a,b,c,d$ – some constants.

Task is to write program (**C++**), which simulates this object temperature.

---

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

Код программы:
```C++
#include <iostream>
#include <fstream>
#include <cmath>

using namespace std;

double calculateFunction1(double y, double u) {
double coefficientA = 0.6;
double coefficientB = 0.5;
return coefficientA * y + coefficientB * u;
}

double calculateFunction2(double y, double u, double y1) {
double coefficientA = 0.6;
double coefficientB = 0.5;
double coefficientC = 0.62;
double coefficientD = 1.1;
return coefficientA * y - coefficientB * pow(y1, 2) + coefficientC * u + coefficientD * sin(u);
}

int main() {
ofstream outputFile("output.txt");

double initialY, initialU;
cout << "Enter initial values for y and u: ";
cin >> initialY >> initialU;

double y1 = initialY;
double y2 = initialY;
double previousY2 = initialY;

int i = 0;
outputFile << i << " " << y1 << " " << y2 << endl;

y1 = calculateFunction1(y1, initialU);
y2 = calculateFunction2(y2, initialU, previousY2);
i++;
outputFile << i << " " << y1 << " " << y2 << endl;

for (i = 2; i < 100; i++) {
y1 = calculateFunction1(y1, initialU);
y2 = calculateFunction2(y2, initialU, previousY2);
previousY2 = y2;
outputFile << i << " " << y1 << " " << y2 << endl;
}

return 0;
}

```

Вывод программы:

0 0 0
1 0.5 1.54562
2 0.8 2.47299
3 0.98 -0.0284257
4 1.088 1.52816
5 1.1528 1.29488
6 1.19168 1.48419
7 1.21501 1.33472
8 1.229 1.45571
9 1.2374 1.3595
10 1.24244 1.4372
11 1.24547 1.37517
12 1.24728 1.42518
13 1.24837 1.38516
14 1.24902 1.41738
15 1.24941 1.39156
16 1.24965 1.41233
17 1.24979 1.39568
18 1.24987 1.40907
19 1.24992 1.39832
20 1.24995 1.40696
21 1.24997 1.40003
22 1.24998 1.4056
23 1.24999 1.40113
24 1.24999 1.40472
25 1.25 1.40183
26 1.25 1.40415
27 1.25 1.40229
28 1.25 1.40378
29 1.25 1.40258
30 1.25 1.40355
31 1.25 1.40277
32 1.25 1.4034
33 1.25 1.4029
34 1.25 1.4033
35 1.25 1.40298
36 1.25 1.40323
37 1.25 1.40303
38 1.25 1.40319
39 1.25 1.40306
40 1.25 1.40317
41 1.25 1.40308
42 1.25 1.40315
43 1.25 1.40309
44 1.25 1.40314
45 1.25 1.4031
46 1.25 1.40313
47 1.25 1.40311
48 1.25 1.40313
49 1.25 1.40311
50 1.25 1.40312
![График моделей с t = 100:](picture.png)
21 changes: 21 additions & 0 deletions trunk/ii02413/task_01/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# CMakeList.txt: проект CMake для lab1111; включите исходный код и определения,
# укажите здесь логику для конкретного проекта.
#
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 ("lab1111")

# Добавьте источник в исполняемый файл этого проекта.
add_executable (lab1111 "Source.cpp" )

if (CMAKE_VERSION VERSION_GREATER 3.12)
set_property(TARGET lab1111 PROPERTY CXX_STANDARD 20)
endif()

# TODO: Добавьте тесты и целевые объекты, если это необходимо.
57 changes: 57 additions & 0 deletions trunk/ii02413/task_01/src/Source.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#include <iostream>
#include <fstream>
#include <cmath>

using namespace std;

// Function declarations
double calculateFunction1(double currentY, double currentU);
double calculateFunction2(double currentY, double currentU, double previousY);

int main() {
double initialY;
double initialU;

cout << "Enter initial values for y and u: ";
cin >> initialY >> initialU;

ofstream outputFile("output.txt");

double y1 = initialY;
double y2 = initialY;
double previousY2 = initialY;

int iteration = 0;
outputFile << iteration << " " << y1 << " " << y2 << endl;

y1 = calculateFunction1(y1, initialU);
y2 = calculateFunction2(y2, initialU, previousY2);
iteration++;
outputFile << iteration << " " << y1 << " " << y2 << endl;

for (iteration = 2; iteration < 100; iteration++) {
y1 = calculateFunction1(y1, initialU);
y2 = calculateFunction2(y2, initialU, previousY2);
previousY2 = y2;
outputFile << iteration << " " << y1 << " " << y2 << endl;
}

return 0;
}

// Function definitions
double calculateFunction1(double currentY, double currentU) {
// Implementation of function 1
double coefficientA = 0.6;
double coefficientB = 0.5;
return coefficientA * currentY + coefficientB * currentU;
}

double calculateFunction2(double currentY, double currentU, double previousY) {
// Implementation of function 2
double coefficientA = 0.6;
double coefficientB = 0.5;
double coefficientC = 0.62;
double coefficientD = 1.1;
return coefficientA * currentY - coefficientB * pow(previousY, 2) + coefficientC * currentU + coefficientD * sin(currentU);
}