This repository has been archived by the owner on Jun 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from TsvetelinKostadinv/develop/Tsvetelin
GUI update
- Loading branch information
Showing
18 changed files
with
777 additions
and
86 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
/bin | ||
/test_results | ||
/.settings | ||
|
||
.project | ||
.classpath | ||
|
||
# Ignore Gradle project-specific cache directory | ||
.gradle | ||
gradle.properties | ||
|
||
# Ignore Gradle build output directory | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,35 @@ | ||
# Simulation-Q | ||
[![Build Status](https://travis-ci.org/TsvetelinKostadinv/Simulation-Q.svg?branch=master)](https://travis-ci.org/TsvetelinKostadinv/Simulation-Q) | ||
A simulation of the inner working of a quantum computer | ||
|
||
**General info about current state** | ||
|
||
Travis CI: [![Build Status](https://travis-ci.org/TsvetelinKostadinv/Simulation-Q.svg?branch=master)](https://travis-ci.org/TsvetelinKostadinv/Simulation-Q) | ||
|
||
## Goals | ||
Simulation-Q is designed to model quantum phenomena in a stable package both for home and research use. | ||
The simulation should be fast enough so it can compete with a real quantum computer. | ||
|
||
## Contribution | ||
Everyone eager enough and excited about this project is free to fork it and work or even contact me([here]([email protected] )) | ||
|
||
|
||
## Implementation details | ||
It started off as a Java project solely because I am most familiar with it. However, it may be ported to a lower level lang one day... | ||
|
||
|
||
## How to test it yourself | ||
This section is likely to change a lot so I am putting it at the bottom. | ||
As of [this commit](https://github.com/TsvetelinKostadinv/Simulation-Q/tree/a5455c2a274b49c0c6c0440cc4c245737e4f0782 "this commit") the project is yet to have a GUI( or a proper CLI for that matter ). Fear not, I am working on it... It will be done, eventually. | ||
So, back on track. | ||
First you have to clone the project, wither way you prefer, you need it on your local machine. | ||
Next to run the project you just need to open command prompt in the main directory and type: | ||
``` | ||
gradlew clean build run | ||
``` | ||
or | ||
``` | ||
./gradlew clean build run | ||
``` | ||
on Unix based systems | ||
This will construct a sample quantum register and apply sample transformations( nothing if I recall correctly ), and collapses it a million times and performs a poor microbenchmark saying how long it took. | ||
However, if you want to tinker with it you can navigate to the file named Presenting.java | ||
At the top you will find constants with explanatory comments so that you can change them up and experiment. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* 20/03/2020 13:17:14 | ||
* QCollapserModel.java created by Tsvetelin | ||
*/ | ||
package com.gui; | ||
|
||
|
||
import java.util.LinkedHashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import com.simulationQ.simulation.computation.QCollapser; | ||
import com.simulationQ.simulation.computation.QFinalStateCalculator; | ||
import com.simulationQ.simulation.computation.program.QProgram; | ||
import com.simulationQ.simulation.computation.qubits.register.CRegister; | ||
import com.simulationQ.simulation.computation.qubits.register.QRegister; | ||
|
||
|
||
/** | ||
* @author Tsvetelin | ||
* | ||
*/ | ||
public interface CollapseDataModel | ||
{ | ||
|
||
// TODO this should take in a Register and a program which will be | ||
// constructed in the controller | ||
static Map< String , Number > generateCollapseData ( final CRegister starting , | ||
final QProgram program , | ||
final int count ) | ||
{ | ||
final Map< String , Number > res = new LinkedHashMap<>(); | ||
if ( starting.size() == 0 ) return res; | ||
|
||
final QRegister finalState = QFinalStateCalculator.calculateFinalState( program , | ||
starting ); | ||
|
||
final List< String > results = QCollapser.generateCollapseData( finalState , | ||
count ); | ||
|
||
for ( String possibility : QCollapser.generateBinaryStringValues( starting.size() ) ) | ||
{ | ||
res.put( possibility , 0 ); | ||
} | ||
|
||
for ( String state : results ) | ||
{ | ||
// res.put( state , res.get( state ).intValue() + 1 ); | ||
res.compute( state , (str, n) -> n.intValue()+1 ); | ||
} | ||
|
||
return res; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* 21/03/2020 14:44:20 | ||
* GUIStarter.java created by Tsvetelin | ||
*/ | ||
package com.gui; | ||
|
||
import javafx.application.Application; | ||
import javafx.fxml.FXMLLoader; | ||
import javafx.scene.Parent; | ||
import javafx.scene.Scene; | ||
import javafx.scene.image.Image; | ||
import javafx.stage.Stage; | ||
|
||
/** | ||
* @author Tsvetelin | ||
* | ||
*/ | ||
public class GUIStarter extends Application implements Runnable | ||
{ | ||
|
||
public static final String FXML_FILE_LOCATION = "main_window.fxml"; | ||
public static final String CSS_FILE_LOCATION = "styles.css"; | ||
public static final String ICON_FILE_LOCATION = "logo.png"; | ||
|
||
public static final String TITLE = "Simulation-Q"; | ||
|
||
@Override | ||
public void start(Stage stage) throws Exception { | ||
Parent root = FXMLLoader.load(getClass().getResource(FXML_FILE_LOCATION)); | ||
|
||
Scene scene = new Scene(root); | ||
scene.getStylesheets().add(getClass().getResource(CSS_FILE_LOCATION).toExternalForm()); | ||
|
||
stage.setTitle(TITLE); | ||
stage.getIcons().add(new Image( getClass().getResourceAsStream(ICON_FILE_LOCATION) )); | ||
stage.setScene(scene); | ||
stage.show(); | ||
} | ||
|
||
@Override | ||
public void run() { | ||
System.out.println( "Starting..." ); | ||
GUIStarter.launch(new String[0]); | ||
} | ||
|
||
public static void main ( String [] args ) | ||
{ | ||
GUIStarter s = new GUIStarter(); | ||
|
||
s.run(); | ||
} | ||
|
||
} |
Oops, something went wrong.