Bookmark this: tool.io/generate/open-shop-scheduling-instance/source-code
Open-Shop Scheduling Instance Generator Source Code
Browse the implementation files for Open-Shop Scheduling Instance Generator.tool.ts typescript
import { parseInteger } from '../../parse/integer/tool';
import { createSeededRandom } from '../../random/seeded-number/tool';
export const generateOpenShopInstance = (
jobsInput: unknown,
machinesInput: unknown,
minimumTimeInput: unknown,
maximumTimeInput: unknown,
seedInput: unknown
): string => {
const jobs = parseInteger(jobsInput);
const machines = parseInteger(machinesInput);
const minimumTime = parseInteger(minimumTimeInput);
const maximumTime = parseInteger(maximumTimeInput);
if (
jobs === null ||
jobs < 1 ||
jobs > 1000 ||
machines === null ||
machines < 1 ||
machines > 1000 ||
jobs * machines > 100_000 ||
minimumTime === null ||
minimumTime < 1 ||
maximumTime === null ||
maximumTime < minimumTime ||
typeof seedInput !== 'string' ||
!seedInput.trim()
)
return '';
const random = createSeededRandom(seedInput);
const processingTimes = Array.from({ length: jobs }, () =>
Array.from(
{ length: machines },
() =>
minimumTime +
Math.floor(random() * (maximumTime - minimumTime + 1))
)
);
return JSON.stringify(
{ jobs, machines, processingTimes, seed: seedInput },
null,
2
);
};
export const Tool: TypeTool = {
name: 'Open-Shop Scheduling Instance Generator',
slug: 'generate/open-shop-scheduling-instance',
intro:
'Generate a reproducible processing-time matrix for an open-shop scheduling problem.',
tool: generateOpenShopInstance,
i: [
{
example: '4',
label: 'Jobs',
placeholder: 'Positive job count',
type: 'number'
},
{
example: '3',
label: 'Machines',
placeholder: 'Positive machine count',
type: 'number'
},
{
example: '1',
label: 'Minimum Processing Time',
placeholder: 'Positive integer',
type: 'number'
},
{
example: '20',
label: 'Maximum Processing Time',
placeholder: 'Maximum integer',
type: 'number'
},
{
example: 'tool.io',
label: 'Seed',
placeholder: 'Reproducible seed',
type: 'text'
}
],
o: [
{
example: '{ "processingTimes": [[4,8,2]] }',
label: 'Open-Shop Instance',
placeholder: 'Instance will appear here...',
render: 'textarea',
type: 'text'
}
],
rerunnable: true,
cite: [
{
title: 'Open-shop scheduling - Wikipedia',
url: 'https://en.wikipedia.org/wiki/Open-shop_scheduling'
}
]
};
export default Tool;
Description
Browse the implementation files for Open-Shop Scheduling Instance Generator.