Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Master/Dev #10

Merged
merged 15 commits into from
Aug 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: Bug report
about: It's broken ¯\_(ツ)_/¯

---

**File**: org/iconic/file.java
**Lines**:
**Branch**:

**Describe the bug**
A clear and concise description of what the bug is.

**To reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Additional context**
Add any other context about the problem here. (eg. **Stacktraces**)
14 changes: 14 additions & 0 deletions .github/ISSUE_TEMPLATE/feature-request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: Feature Request
about: Improvements and TODOs

---

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
28 changes: 28 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# How to contribute
I'm really glad you're reading this.

## Merges into higher branches
This section is for merging your changes into the development branch (and later the master branch).
Make sure you run every unit test in the suite before creating your pull request. We don't want any regressions. Once you've done this, you're good to make your very own Pull Request!

### Creating a Pull Request (PR)
- Merges from any branch into *development* and *master* must go through a GitHub PR.
- Each PR must be assigned to me ([@scottwalkerau](https://github.com/scottwalkerau)) and have someone relevant as a reviewer. (Try not to add too many people as reviewers, at most 2)
- If you cannot think of someone relevant, leave it blank and I will do it myself or assign someone.
- Add any relevant comments for reviewers and myself on the PR. (There is a very small template for this)

### Reviewing a PR
- Read through every line changed so you understand **why** the PR is there.
- Flag any overall questions you have as a **Comment**
- Flag anything general you think should be done differently as **Request Changes** (For specific sections of the code, see below)
- If you think **every file** is good, select **Approve**

*NOTE:*
- You can select individual lines for single comments or starting a review.
- Selecting one of the three radio buttons applies the action to every file and doesn't reference a specific line.

## Coding conventions
I'm hoping you all adhere to these when writing your code. It will increase readability for your reviewers and maintainability later on...
- No single line *if*, *while*, *for*, etc. structures without curly braces. Use curly braces.
- Each method that does not call a subroutine should perform at most 1 function. (eg. A method to translate numbers to excel headers should not be buried within another function, it should be its own)
- If your methods are too long, create a private subroutine.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 Iconic

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 2 additions & 0 deletions PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**Changes**
Describe what this merge will change
3 changes: 2 additions & 1 deletion api/src/main/java/org/iconic/ea/chromosome/Chromosome.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.iconic.ea.chromosome;

import org.iconic.ea.data.DataManager;
import org.iconic.ea.operator.evolutionary.mutation.Mutator;

import java.util.LinkedList;
Expand Down Expand Up @@ -96,7 +97,7 @@ public void setChanged(boolean changed) {
* @param input The input samples to evaluate
* @return A list of outputs, one for each input sample
*/
public abstract List<T> evaluate(List<List<T>> input);
public abstract List<T> evaluate(final DataManager<T> input);

/**
* <p>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package org.iconic.ea.chromosome.expression;

import lombok.extern.log4j.Log4j2;
import org.iconic.ea.chromosome.Chromosome;
import org.iconic.ea.chromosome.LinearChromosome;
import org.iconic.ea.chromosome.graph.Node;
import org.iconic.ea.chromosome.TreeChromosome;
import org.iconic.ea.chromosome.graph.Node;
import org.iconic.ea.data.DataManager;
import org.iconic.ea.data.FeatureClass;

import java.util.LinkedList;
import java.util.List;
Expand All @@ -13,6 +16,7 @@
* {@inheritDoc}
* <p>A chromosome that encodes an expression tree.</p>
*/
@Log4j2
public class ExpressionChromosome<T> extends Chromosome<T> implements TreeChromosome<T>, LinearChromosome<Node<T>>, Cloneable {
private List<Node<T>> genome;
private Node<T> root;
Expand Down Expand Up @@ -91,11 +95,24 @@ private Node<T> recursivelyGenerateTree(Node<T> root) {
* {@inheritDoc}
*/
@Override
public List<T> evaluate(List<List<T>> input) {
public List<T> evaluate(final DataManager<T> dataManager) {
List<T> calculatedValues = new LinkedList<>();
List<String> headers = dataManager.getSampleHeaders();
int numSamples = dataManager.getSampleSize();

for (int i = 0; i < numSamples; ++i) {
List<T> row = new LinkedList<>();

for (String header : headers) {
FeatureClass<Number> feature = dataManager.getDataset().get(header);

row.add(
(T) feature.getSampleValue(i)
);
}

for (List<T> row : input) {
calculatedValues.add(getRoot().apply(row));
T output = getRoot().apply(row);
calculatedValues.add(output);
}

return calculatedValues;
Expand Down
Loading