Skip to content

Commit

Permalink
refactoring nonconvex optimization into its own class
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadyan committed Sep 8, 2016
1 parent 75e7115 commit 893b996
Show file tree
Hide file tree
Showing 13 changed files with 1,036 additions and 538 deletions.
1 change: 0 additions & 1 deletion bin/simple.cfg
Expand Up @@ -5,7 +5,6 @@

Duplex {
name = "Monkey Saddle Point optimization";

mode = "opt";
iterations = "1000";
output = working_directory + "simple.png";
Expand Down
Binary file added doc/class-diagram.graffle
Binary file not shown.
514 changes: 54 additions & 460 deletions src/duplex.cpp

Large diffs are not rendered by default.

118 changes: 51 additions & 67 deletions src/duplex.h
@@ -1,11 +1,5 @@
//
// duplex.h
// duplex
//
// Created by Adel Ahmadyan on 4/23/15.
// Copyright (c) 2015 Adel Ahmadyan. All rights reserved.
//
#pragma once
#include <iostream>
#include <boost/property_tree/ptree.hpp>

#include "configuration.h"
Expand All @@ -14,82 +8,72 @@
#include "stat.h"
#include "data.h"

using namespace std;

enum class Temperature { temperatureexp, temperaturefast, temperatureboltz };
enum class Annealing { annealingfast, annealingboltz, annealingfastrandom, annealingboltzrandom};

class Duplex{
Settings* settings;

protected:
Settings* settings;
Search* db;
Stat* stat;
Stat* stat;
System* system;

//System:
State* root;
State* goal;
System* system;
double* max;
double* min;
double* opt;
int parameterDimension;
int objectiveDimension;

//Duplex options
int iterationCap;
Temperature temperatureOption;
Annealing annealingOption;
double t0; //initial temperature
double temperature; //current temperature
double stepLength;
double initialStepLength;
bool reinforcementLearningOption;
bool shrinkGoalRegionWithTemperateOption;
int nextCandidateParameter;

//Duplex outputs:

double minAward;
double maxAward;
double delta;
//System:
State* goal;
double* max;
double* min;
double* opt;
int parameterDimension;
int objectiveDimension;

//Duplex options
int iterationCap;
Temperature temperatureOption;
Annealing annealingOption;
double t0; //initial temperature
double temperature; //current temperature
double stepLength;
double initialStepLength;
bool reinforcementLearningOption;
bool shrinkGoalRegionWithTemperateOption;
int nextCandidateParameter;

//Duplex outputs:
double minAward;
double maxAward;
double delta;
double* goalRegionBoxMin;
double* goalRegionBoxMax;
double* parameterMin;
double* parameterMax;
vector<string> objectiveType;

double* parameterMin;
double* parameterMax;
vector<string> objectiveType;
public:
Duplex(Settings*);
Duplex(Settings* s);
~Duplex();
double* getInitialState();
void setSystem(System*);
void initialize();
void setObjective();

void walkOptimizer();
void optimize();
void simulated_annealing();
void functionalOptimization();
void treeOptimizer();

//plotting methods
string draw(int);
string drawParameterTree(int x, int y, int z, string sizingPreference, string plotType, string title);
string drawObjectiveTree(int, int, string);
string drawTrace(int x, int y, string title);
string drawCanvas(string function, double xmin, double xmax, double ymin, double ymax, string, string);
//initialization methods

// methods handling input data

// methods for optimizing the function
virtual State* initialize()=0;
void insert(int i, State* qnear, State* qnew);
double score(State*, double*, double*);
double* generateNewInput(State* q);
State* localStep(int i, State*);
State* globalStep();
State* foptGlobalStep();
virtual State* globalStep()=0;
virtual State* localStep(int, State*)=0;
virtual double evaluate(State*)=0;
virtual bool isConverged(int)=0;
void optimize();
void train();

void computeTemperature(int i);
double computeStepLength();
int computeNextCandidateParameter(State* qnear);
Search* getDB();
System* getSystem();
// aux methods, loading, saving, etc.
void save(boost::property_tree::ptree* ptree);
void load(boost::property_tree::ptree* ptree);
Search* getDB();
System* getSystem();
void setStat(Stat*);
Stat* getStat();
};
};

0 comments on commit 893b996

Please sign in to comment.