Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ypchen-tw committed Dec 22, 2020
0 parents commit 050b73d
Show file tree
Hide file tree
Showing 330 changed files with 5,536 additions and 0 deletions.
65 changes: 65 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
cf.composer
========

Supplemental data and obtained results for "AntsOMG: A Framework Aiming to Automate Creativity and Intelligent Behavior with A Showcase on Cantus Firmus Composition and Style Development"

----------


Style Model 1
------------

*Ascending and descending scales in a five-note group is the most frequently seen in this style, which creates an interesting flavor as in playing on a slide.*

Stepwise motions are greatly preferred in cantus firmus style. This Style Model is characterized with successive stepwise motions in the same direction, which appears at least four times to form a five-note group.

[Scores & links of the music created from Style Model 1](StyleModel1.md)


Style Model 2
------------

*More daring with larger disjunct (over fourth), some beautiful combinations would be created. It is especially interesting with a downward progression of the fourth at the beginning.*

In this model the cantus firmi are featured with at least one leap in interval of octave and two leaps in intervals greater than thirds.

[Scores & links of the music created from Style Model 2](StyleModel2.md)


Style Model 3
------------

*A mixture of stepwise motion and thirds, sometimes with an exotic flavor of the pentatonic scale.*

In this Style Model, the melodic interval of cantus firmi is mainly comprised of seconds and thirds, and the combination of a successive seconds and thirds (or vice versa) takes at least 50%.

[Scores & links of the music created from Style Model 3](StyleModel3.md)


Style Model 4
------------

*Often going upwards with stepwise motion mixed with thirds from the very beginning, continues to the distance of the seventh, or even a bit further at times.*

The cantus firmi with successive upward stepwise and thirds motions.

[Scores & links of the music created from Style Model 4](StyleModel4.md)


Style Model 5
------------

*Swinging up and down to find a balance at the beginning of the work, forming a lingering figure.*

In this Style Model the cantus firmi are initiated with a four-note figure comprised of intervals less than fifth with at least one interval greater than second, and the successive notes are going in opposite directions.

[Scores & links of the music created from Style Model 5](StyleModel5.md)

----------

Use
___

Please cite

> Chang, C.-y., & Chen, Y.-p. (2020). AntsOMG: A Framework Aiming to Automate Creativity and Intelligent Behavior with a Showcase on Cantus Firmus Composition and Style Development. <i>Electronics</i>, 9(8), 1212. doi: [10.3390/electronics9081212](http://dx.doi.org/10.3390/electronics9081212).
247 changes: 247 additions & 0 deletions StyleModel1.md

Large diffs are not rendered by default.

272 changes: 272 additions & 0 deletions StyleModel2.md

Large diffs are not rendered by default.

272 changes: 272 additions & 0 deletions StyleModel3.md

Large diffs are not rendered by default.

272 changes: 272 additions & 0 deletions StyleModel4.md

Large diffs are not rendered by default.

272 changes: 272 additions & 0 deletions StyleModel5.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions code/antsomg/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target/
46 changes: 46 additions & 0 deletions code/antsomg/nbactions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<actions>
<action>
<actionName>run</actionName>
<packagings>
<packaging>jar</packaging>
</packagings>
<goals>
<goal>process-classes</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:1.5.0:exec</goal>
</goals>
<properties>
<exec.args>--enable-preview -classpath %classpath tech.metacontext.ocnhfa.antsomg.demo.Main</exec.args>
<exec.executable>java</exec.executable>
</properties>
</action>
<action>
<actionName>debug</actionName>
<packagings>
<packaging>jar</packaging>
</packagings>
<goals>
<goal>process-classes</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:1.5.0:exec</goal>
</goals>
<properties>
<exec.args>-agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address} --enable-preview -classpath %classpath tech.metacontext.ocnhfa.antsomg.demo.Main</exec.args>
<exec.executable>java</exec.executable>
<jpda.listen>true</jpda.listen>
</properties>
</action>
<action>
<actionName>profile</actionName>
<packagings>
<packaging>jar</packaging>
</packagings>
<goals>
<goal>process-classes</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:1.5.0:exec</goal>
</goals>
<properties>
<exec.args>--enable-preview -classpath %classpath tech.metacontext.ocnhfa.antsomg.demo.Main</exec.args>
<exec.executable>java</exec.executable>
</properties>
</action>
</actions>
55 changes: 55 additions & 0 deletions code/antsomg/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>tech.metacontext.ocnhfa</groupId>
<artifactId>antsomg</artifactId>
<version>2.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Ants on Multiple Graphs</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>14</maven.compiler.source>
<maven.compiler.target>14</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<compilerArgs>
<arg>--enable-preview</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>2.1.3</version>
<type>jar</type>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* Copyright 2019 Jonathan Chang, Chun-yien <[email protected]>.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package tech.metacontext.ocnhfa.antsomg.demo;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import tech.metacontext.ocnhfa.antsomg.model.Ant;
import tech.metacontext.ocnhfa.antsomg.impl.StandardMove;
import tech.metacontext.ocnhfa.antsomg.demo.x.Edge_X;
import tech.metacontext.ocnhfa.antsomg.demo.x.Vertex_X;
import tech.metacontext.ocnhfa.antsomg.demo.y.Edge_Y;
import tech.metacontext.ocnhfa.antsomg.demo.y.Vertex_Y;
import tech.metacontext.ocnhfa.antsomg.demo.z.Edge_Z;
import tech.metacontext.ocnhfa.antsomg.demo.z.Vertex_Z;

/**
*
* @author Jonathan Chang, Chun-yien <[email protected]>
*/
public class DemoAnt implements Ant<DemoTrace> {

DemoTrace currentTrace;
List<DemoTrace> route;
private boolean completed;

public DemoAnt(Vertex_X x, Vertex_Y y, Vertex_Z z) {

this.currentTrace = new DemoTrace(
new StandardMove<>(new Edge_X(x)),
new StandardMove<>(new Edge_Y(y)),
new StandardMove<>(new Edge_Z(z)));
this.route = new ArrayList<>();
}

@Override
public List<DemoTrace> getRoute() {

return this.route;
}

@Override
public void addCurrentTraceToRoute() {

this.route.add(this.currentTrace);
}

@Override
public DemoTrace getCurrentTrace() {

return this.currentTrace;
}

@Override
public void setCurrentTrace(DemoTrace trace) {

if (Objects.nonNull(this.currentTrace)) {
this.addCurrentTraceToRoute();
}
this.currentTrace = trace;
}

public boolean isCompleted() {

return completed;
}

public void setCompleted(boolean completed) {

this.completed = completed;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/*
* Copyright 2019 Jonathan Chang, Chun-yien <[email protected]>.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package tech.metacontext.ocnhfa.antsomg.demo;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import tech.metacontext.ocnhfa.antsomg.model.AntsOMGSystem;
import tech.metacontext.ocnhfa.antsomg.impl.StandardGraph;
import tech.metacontext.ocnhfa.antsomg.demo.z.Graph_Z;
import tech.metacontext.ocnhfa.antsomg.demo.y.Graph_Y;
import tech.metacontext.ocnhfa.antsomg.demo.x.Graph_X;

/**
*
* @author Jonathan Chang, Chun-yien <[email protected]>
*/
public class DemoSystem implements AntsOMGSystem<DemoAnt> {

int ant_population;
Map<String, ? extends StandardGraph> graphs;
List<DemoAnt> ants;
double pheromone_deposit = 0.1, explore_chance = 0.1, evaporate_rate = 0.05;
double alpha = 1.0, beta = 1.0;

public DemoSystem(int ant_population) {

this.ant_population = ant_population;
}

@Override
public void init_graphs() {

this.graphs = Map.of(
"x", new Graph_X(alpha, beta),
"y", new Graph_Y(alpha, beta * 2),
"z", new Graph_Z(alpha * 2, beta)
);
}

@Override
public void init_population() {

this.ants = Stream.generate(()
-> new DemoAnt(
getX().getStart(),
getY().getStart(),
getZ().getStart()))
.limit(ant_population)
.collect(Collectors.toList());
}

Graph_X getX() {

return (Graph_X) this.graphs.get("x");
}

Graph_Y getY() {

return (Graph_Y) this.graphs.get("y");
}

Graph_Z getZ() {

return (Graph_Z) this.graphs.get("z");
}

@Override
public void navigate() {

this.ants.stream().forEach(ant -> {
if (!ant.isCompleted()) {
var trace = ant.getCurrentTrace();
var x = getX().move(trace.getX().getSelected().getTo(),
this.pheromone_deposit, this.explore_chance);
var y = getY().move(trace.getY().getSelected().getTo(),
this.pheromone_deposit, this.explore_chance);
var z = getZ().move(trace.getZ().getSelected().getTo(),
this.pheromone_deposit, this.explore_chance);
var new_trace = new DemoTrace(x, y, z);
ant.setCurrentTrace(new_trace);
if (new_trace.getDimension("x").equals(getX().getStart())
&& new_trace.getDimension("y").equals(getY().getStart())
&& new_trace.getDimension("z").equals(getZ().getStart())) {
ant.addCurrentTraceToRoute();
ant.setCompleted(true);
}
}
});
this.evaporate();
}

@Override
public void evaporate() {

List.of(getX().getEdges(), getY().getEdges(), getZ().getEdges())
.stream()
.flatMap(List::stream)
.forEach(edge -> edge.evaporate(evaporate_rate));
}

@Override
public boolean isAimAchieved() {

return this.ants.stream().allMatch(DemoAnt::isCompleted);
}

@Override
public Map<String, ? extends StandardGraph> getGraphs() {

return this.graphs;
}

@Override
public List<DemoAnt> getAnts() {

return this.ants;
}
}
Loading

0 comments on commit 050b73d

Please sign in to comment.