MitchellHansen 8 years ago
commit 101155c6d6

324
.gitignore vendored

@ -0,0 +1,324 @@
# Prerequisites
*.d
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
*.smod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
*.exe
*.out
*.app
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
*.vcxproj.filters
#### Non default values !!!!!!!!!!!!!
*.vcxproj
*.sln
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
**/Properties/launchSettings.json
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignoreable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush
.cr/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/
CMakeCache.txt
CMakeFiles
CMakeScripts
Makefile
cmake_install.cmake
install_manifest.txt
CTestTestfile.cmake

@ -0,0 +1,29 @@
cmake_minimum_required(VERSION 3.4.3)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
file(GLOB l4_SOURCES "lab4/*.cpp" "lab4/*.c")
file(GLOB l4_HEADERS "lab4/*.h" "lab4/*.hpp")
add_executable(Lab4 ${l4_SOURCES} ${l4_HEADERS})
set_target_properties(Lab4 PROPERTIES LINKER_LANGUAGE CXX)
file(GLOB l3_SOURCES "lab3/*.cpp" "lab3/*.c")
file(GLOB l3_HEADERS "lab3/*.h" "lab3/*.hpp")
add_executable(Lab3 ${l3_SOURCES} ${l3_HEADERS})
set_target_properties(Lab3 PROPERTIES LINKER_LANGUAGE CXX)
file(GLOB l2_SOURCES "lab2/*.cpp" "lab2/*.c")
file(GLOB l2_HEADERS "lab2/*.h" "lab2/*.hpp")
add_executable(Lab2 ${l2_SOURCES} ${l2_HEADERS})
set_target_properties(Lab2 PROPERTIES LINKER_LANGUAGE CXX)
file(GLOB l1_SOURCES "lab1/*.cpp" "lab1/*.c")
file(GLOB l1_HEADERS "lab1/*.h" "lab1/*.hpp")
add_executable(Lab1 ${l1_SOURCES} ${l1_HEADERS})
set_target_properties(Lab1 PROPERTIES LINKER_LANGUAGE CXX)

@ -1,17 +1,11 @@
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream> #include <iostream>
#include <vector> #include <vector>
#include <cmath>
#include <map> #include <map>
#include <chrono> #include <chrono>
#include "SFML/Graphics.hpp"
#include "mtrand.h" #include "mtrand.h"
#include <algorithm>
// In order to compile and run this project you're going to either comment out the SFML
// code or install SFML which is trivial on *NIX.
// Just apt-get install libsfml-dev
// or brew install sfml
std::vector<double> c = {0.806,0.517,0.1,0.908,0.965,0.669,0.524,0.902,0.351,0.876,0.462, std::vector<double> c = {0.806,0.517,0.1,0.908,0.965,0.669,0.524,0.902,0.351,0.876,0.462,
@ -474,72 +468,6 @@ struct function{
}; };
void draw(){
int bounds = fabs(upper_bound) + fabs(lower_bound);
int window_xy = 1024;
sf::RenderWindow window(sf::VideoMode(window_xy, window_xy), "Functions");
sf::Uint8* pixel_array = new sf::Uint8[window_xy * window_xy * 4];
sf::Texture texture;
texture.create(window_xy, window_xy);
sf::Sprite sprite(texture);
double min = 9999999;
double max = 0;
for (int i = 0; i < window_xy * window_xy * 4; i += 4) {
std::vector<double> position =
{static_cast<double>(set_within(((i / 4) % window_xy) - window_xy/2, 512, -512, upper_bound, lower_bound)),
static_cast<double>(set_within(((i / 4) / window_xy) - window_xy/2, 512, -512, upper_bound, lower_bound))};
auto res = static_cast<double>(compute_defined(position));
if (res > max)
max = res;
if (res < min)
min = res;
}
for (int i = 0; i < window_xy * window_xy * 4; i += 4){
std::vector<double> position =
{static_cast<double>(set_within(((i / 4) % window_xy) - window_xy/2, 512, -512, upper_bound, lower_bound)),
static_cast<double>(set_within(((i / 4) / window_xy) - window_xy/2, 512, -512, upper_bound, lower_bound))};
auto res = static_cast<int>((((compute_defined(position) - min) * (16581375 - 0)) / (max - min)) + 0);
pixel_array[i + 0] = res & 0xff;
pixel_array[i + 1] = (res>>8) & 0xff;
pixel_array[i + 2] = (res>>16) & 0xff;
pixel_array[i + 3] = 255;
//pixel_array[i + 0] = res;
//pixel_array[i + 1] = 255;
//pixel_array[i + 2] = 255;
//pixel_array[i + 3] = 255;
}
texture.update(pixel_array);
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(sprite);
window.display();
}
delete pixel_array;
};
}; };
int main() { int main() {
@ -566,21 +494,6 @@ int main() {
function masters_cosine_wave_f(&masters_cosine_wave, 30, -30); function masters_cosine_wave_f(&masters_cosine_wave, 30, -30);
function shekels_foxholes_f(&shekels_foxholes, 10, 0); function shekels_foxholes_f(&shekels_foxholes, 10, 0);
// shekels_foxholes_f.draw();
// schwefel_f.draw();
// de_jong_f.draw();
// rosenbrock_f.draw();
// rastrigin_f.draw();
// griegwangk_f.draw();
// sine_envelope_sine_wave_f.draw();
// stretched_v_sine_wave_f.draw();
// ackleys_one_f.draw();
// ackleys_two_f.draw();
// egg_holder_f.draw();
// rana_f.draw();
// pathological_f.draw();
// michalewicz_f.draw();
// masters_cosine_wave_f.draw();
std::string vals[] { std::string vals[] {
"MEAN", "MEDIAN", "DEVIATION", "AVG_TIME", "DIMENSIONALIY", "UPPER_RANGE", "LOWER_RANGE" "MEAN", "MEDIAN", "DEVIATION", "AVG_TIME", "DIMENSIONALIY", "UPPER_RANGE", "LOWER_RANGE"

@ -1,3 +1,6 @@
#pragma once
#define _USE_MATH_DEFINES
#include <math.h>
std::vector<double> c = {0.806,0.517,0.1,0.908,0.965,0.669,0.524,0.902,0.351,0.876,0.462, std::vector<double> c = {0.806,0.517,0.1,0.908,0.965,0.669,0.524,0.902,0.351,0.876,0.462,
0.491,0.463,0.741,0.352,0.869,0.813,0.811,0.0828,0.964,0.789,0.360,0.369, 0.491,0.463,0.741,0.352,0.869,0.813,0.811,0.0828,0.964,0.789,0.360,0.369,

@ -59,7 +59,10 @@ public:
global_best_solution = best_solution; global_best_solution = best_solution;
} }
} }
return func.compute(global_best_solution);
}; };
}; };

@ -1,3 +1,6 @@
#pragma once
#define _USE_MATH_DEFINES // for C++
#include <math.h>
std::vector<double> c = {0.806,0.517,0.1,0.908,0.965,0.669,0.524,0.902,0.351,0.876,0.462, std::vector<double> c = {0.806,0.517,0.1,0.908,0.965,0.669,0.524,0.902,0.351,0.876,0.462,
0.491,0.463,0.741,0.352,0.869,0.813,0.811,0.0828,0.964,0.789,0.360,0.369, 0.491,0.463,0.741,0.352,0.869,0.813,0.811,0.0828,0.964,0.789,0.360,0.369,

@ -59,6 +59,8 @@ public:
global_best_solution = best_solution; global_best_solution = best_solution;
} }
} }
return func.compute(global_best_solution);
}; };
}; };

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.5.1) cmake_minimum_required(VERSION 3.4.3)
project(Lab4) add_project(Lab4)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})

@ -1,3 +1,6 @@
#pragma once
#define _USE_MATH_DEFINES // for C++
#include <math.h>
std::vector<double> c = {0.806,0.517,0.1,0.908,0.965,0.669,0.524,0.902,0.351,0.876,0.462, std::vector<double> c = {0.806,0.517,0.1,0.908,0.965,0.669,0.524,0.902,0.351,0.876,0.462,
0.491,0.463,0.741,0.352,0.869,0.813,0.811,0.0828,0.964,0.789,0.360,0.369, 0.491,0.463,0.741,0.352,0.869,0.813,0.811,0.0828,0.964,0.789,0.360,0.369,

@ -59,6 +59,8 @@ public:
global_best_solution = best_solution; global_best_solution = best_solution;
} }
} }
return func.compute(global_best_solution);
}; };
}; };

Loading…
Cancel
Save