https://github.com/sepppenner/silvermealheuristic
SilverMeal is a software to calculate the SilverMeal-Problem
https://github.com/sepppenner/silvermealheuristic
Last synced: about 1 month ago
JSON representation
SilverMeal is a software to calculate the SilverMeal-Problem
- Host: GitHub
- URL: https://github.com/sepppenner/silvermealheuristic
- Owner: SeppPenner
- License: mit
- Created: 2017-03-28T20:06:57.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2020-06-04T15:20:13.000Z (about 6 years ago)
- Last Synced: 2025-02-24T03:30:48.987Z (over 1 year ago)
- Language: Java
- Homepage:
- Size: 16.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: Changelog.md
- License: License.txt
Awesome Lists containing this project
README
# SilverMeal
SilverMeal is an example on how to calculate the SilverMeal-Problem: https://de.wikipedia.org/wiki/Silver-Meal_Heuristik
The example was written and tested in Java.
[](https://ci.appveyor.com/project/SeppPenner/silvermealheuristic)
[](https://github.com/SeppPenner/SilverMeal/issues)
[](https://github.com/SeppPenner/SilverMeal/network)
[](https://github.com/SeppPenner/SilverMeal/stargazers)
[](https://raw.githubusercontent.com/SeppPenner/SilverMeal/master/License.txt)
## Basic usage:
```java
package silvermeal;
import java.text.DecimalFormat;
import java.util.HashMap;
public class Main {
private static final DecimalFormat DF = new DecimalFormat("#.00");
public static void main(String[] args) {
SilverMeal silverMeal = new SilverMeal();
checkEightEight(silverMeal);
checkEightNine(silverMeal);
checkNineNine(silverMeal);
checkNineTen(silverMeal);
checkNineEleven(silverMeal);
checkElevenEleven(silverMeal);
checkElevenTwelve(silverMeal);
}
private static final HashMap DEMANDS;
static{
DEMANDS = new HashMap<>();
DEMANDS.put(1,0);
DEMANDS.put(2,0);
DEMANDS.put(3,0);
DEMANDS.put(4,0);
DEMANDS.put(5,0);
DEMANDS.put(6,0);
DEMANDS.put(7,0);
DEMANDS.put(8,27);
DEMANDS.put(9,22);
DEMANDS.put(10,13);
DEMANDS.put(11,19);
DEMANDS.put(12,12);
}
private static void checkEightEight(SilverMeal silverMeal){
double eightEight = silverMeal.calculate(8,8,200,10, DEMANDS);
System.out.println(DF.format(eightEight));
//200 correct
}
private static void checkEightNine(SilverMeal silverMeal){
double EightNine = silverMeal.calculate(8,9,200,10, DEMANDS);
System.out.println(DF.format(EightNine));
//210 correct
}
private static void checkNineNine(SilverMeal silverMeal){
double NineNine = silverMeal.calculate(9,9,200,10, DEMANDS);
System.out.println(DF.format(NineNine));
//200 correct
}
private static void checkNineTen(SilverMeal silverMeal){
double NineTen = silverMeal.calculate(9,10,200,10, DEMANDS);
System.out.println(DF.format(NineTen));
//165 correct
}
private static void checkNineEleven(SilverMeal silverMeal){
double NineEleven = silverMeal.calculate(9,11,200,10, DEMANDS);
System.out.println(DF.format(NineEleven));
//236,66 correct
}
private static void checkElevenEleven(SilverMeal silverMeal){
double ElevenEleven = silverMeal.calculate(11,11,200,10, DEMANDS);
System.out.println(DF.format(ElevenEleven));
//200 correct
}
private static void checkElevenTwelve(SilverMeal silverMeal){
double ElevenTwelve = silverMeal.calculate(11,12,200,10, DEMANDS);
System.out.println(DF.format(ElevenTwelve));
//160 correct
}
}
```
Change history
--------------
See the [Changelog](https://github.com/SeppPenner/SilverMeal/blob/master/Changelog.md).