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

Initial commit #33

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
95 changes: 95 additions & 0 deletions endpoints.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@

{
"rvea/setPreferenceType": {
"description": "UNECESSARY - POST - Sets the type of preference for the optimization algorithm. The preference type influences how the algorithm prioritizes objectives.",
"inputs": {
"preferenceType": "Reference point | Preferred ranges | Preferred solutions | Non-preferred solutions | No preference"
},
"outputs": {
"status": 200,
"message": "Preference type set successfully"
}
},
"rvea/iterateWithReferencePoint": {
"description": "POST - Iterates the optimization process using the 'Reference Point' preference type. Users provide a single value for each objective.",
"inputs": {
"referencePoints": {
"objective1": "number",
"objective2": "number",
"...": "..."
}
},
"outputs": {
"status": 200,
"results": ["solution", "solution", "..."]
}
},
"rvea/iterateWithPreferredRanges": {
"description": "POST - Iterates the optimization process using the 'Preferred Ranges' preference type. Users provide minimum and maximum values for each objective.",
"inputs": {
"preferredRanges": {
"objective1": {"min": "number", "max": "number"},
"objective2": {"min": "number", "max": "number"},
"...": {"min": "...", "max": "..."}
}
},
"outputs": {
"status": 200,
"results": ["solution", "solution", "..."]
}
},
"rvea/iterateWithPreferredSolutions": {
"description": "POST - Iterates the optimization process using the 'Preferred Solutions' preference type. Users select preferred solutions from a given set.",
"inputs": {
"preferredSolutions": ["solution", "solution", "..."]
},
"outputs": {
"status": 200,
"results": ["solution", "solution", "..."]
}
},
"rvea/iterateWithNonPreferredSolutions": {
"description": "POST - Iterates the optimization process using the 'Non-Preferred Solutions' preference type. Users select non-preferred solutions from a given set.",
"inputs": {
"nonPreferredSolutions": ["solution1", "solution2", "..."]
},
"outputs": {
"status": 200,
"results": ["solution", "solution", "..."]
}
},
"rvea/iterateWithNoPreference": {
"description": "POST - Iterates the optimization process using the 'No Preference' type. No specific preference information is required from the user.",
"inputs": {},
"outputs": {
"status": 200,
"results": ["solution", "solution", "..."]
}
},
"rvea/getMethodName": {
"description": "Get - Retrieves the name of the method in use.",
"inputs": {},
"outputs": {
"status": 200,
"method": "name"
}
},
"rvea/getInstructions": {
"description": "Get - Retrieves the instructions for the method.",
"inputs": {},
"outputs": {
"status": 200,
"method": "instructions"
}
},
"rvea/saveSelectedSolutions": {
"description": "POST - Saves the currently selected solutions.",
"inputs": {
"selectedSolutions": ["solution1", "solution2", "..."]
},
"outputs": {
"status": 200,
"message": "Selected solutions saved successfully"
}
}
}
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,3 +481,6 @@ export function is_point_of_length(value: unknown, n: number): value is Point {
export function problem_has_finite_bounds(problem: Problem) {
return is_point(problem.ideal_point) && is_point(problem.nadir_point);
}

export const methodHeaderText = writable("No method selected yet");
export const selectedProblem = writable({} as Problem);
2 changes: 1 addition & 1 deletion src/lib/components/main/SelectMethod.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// },
{
id: "reference_point_method",
display: "Reference Point Method",
display: "Interactive RVEA",
},
];

Expand Down
28 changes: 27 additions & 1 deletion src/lib/components/main/SelectProblem.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
<script lang="ts">
import { onMount } from 'svelte';
import type { Problem } from "$lib/api";

// Dummy problem for testing Interactive RVEA UI
const manufacturingOptimizationProblem: Problem = {
id: 1,
name: "Manufacturing Optimization Problem",
type: "Manufacturing",
objectives: [
{ name: "Cost", minimize: true },
{ name: "Quality", minimize: false },
{ name: "Environmental Impact", minimize: true }
],
variables: [
{ name: "Material Type" },
{ name: "Production Speed" },
{ name: "Temperature" }
],
n_constraints: 0,
ideal_point: [100, 95, 10], // Ideal low cost, high quality, low environmental impact
nadir_point: [500, 50, 100] // Worst case high cost, low quality, high environmental impact
};

export let problems: Problem[];
export let selected_problem: Problem | undefined = undefined;
export let selected_problem: Problem | undefined = manufacturingOptimizationProblem; // Dummy problem set as default
export let hide_saved = false;

import { TabGroup, Tab } from "@skeletonlabs/skeleton";
Expand All @@ -15,6 +36,11 @@
* because saving problems is not yet supported.
*/
let tab = 1;

// Dummy problem added, cannot select from list so set as default
onMount(() => {
problems = [...problems, manufacturingOptimizationProblem];
});
</script>

<div class="grid grid-cols-2 gap-10">
Expand Down
63 changes: 36 additions & 27 deletions src/lib/components/main/Solve.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,47 @@
// Context API?
//

import { login_status, LoginStatus } from "$lib/api";
import type { Problem } from "$lib/api";
import {
login_status,
LoginStatus,
methodHeaderText,
selectedProblem,
type Problem,
} from "$lib/api";

export let problems: Problem[];

import { TabGroup, Tab } from "@skeletonlabs/skeleton";
import SelectProblem from "./SelectProblem.svelte";
import SelectMethod from "./SelectMethod.svelte";
import SolveProblem from "./SolveProblem.svelte";
import { goto } from "$app/navigation";
import { Tab, TabGroup } from "@skeletonlabs/skeleton";
import GeneralError from "../util/undecorated/GeneralError.svelte";
import SelectMethod from "./SelectMethod.svelte";
import SelectProblem from "./SelectProblem.svelte";

let tab = 0;
let selected_problem: Problem | undefined = undefined;
let selected_problem: Problem;
let selected_method = "";
</script>

function goto_solve() {
console.log("selected_problem", selected_problem);

if (selected_method === "nimbus") {
methodHeaderText.set("NIMBUS");
} else if (selected_method === "nautilus") {
methodHeaderText.set("NAUTILUS");
selectedProblem.set(selected_problem);
} else if (selected_method === "nautnavi") {
methodHeaderText.set("NAUTILUS Navigator");
} else if (selected_method === "reference_point_method") {
methodHeaderText.set("Interactive RVEA");
selectedProblem.set(selected_problem);
} else {
throw new Error("No method selected yet.");
}
console.log("selected_method", selected_method);

goto("/solve");
}
</script>
<TabGroup>
<Tab bind:group={tab} name="select_problem" value={0}>1. Select a problem</Tab
>
Expand All @@ -29,22 +54,15 @@
>
{/if}
{#if selected_problem && selected_method}
<Tab bind:group={tab} name="solve_problem" value={2}
<Tab bind:group={tab} name="solve_problem" value={2} on:click={goto_solve}
>3. Solve the problem</Tab
>
{/if}

<svelte:fragment slot="panel">
{#if tab === 0}
<div class="mb-8">
Please select a problem. Then <button
class="anchor"
on:click={() => {
tab = 1;
}}
disabled={!selected_problem}
>continue to selecting a solution method</button
>.
Please select a problem. Then continue to selecting a solution method.
</div>
<SelectProblem
{problems}
Expand All @@ -53,18 +71,9 @@
/>
{:else if tab === 1 && selected_problem}
<div class="mb-8">
Please select a solution method. Then <button
class="anchor"
on:click={() => {
tab = 2;
}}
disabled={!selected_problem || !selected_method}
>continue to solving the problem</button
>.
Please select a solution method. Then continue to solving the problem.
</div>
<SelectMethod problem={selected_problem} bind:selected_method />
{:else if tab === 2 && selected_problem && selected_method}
<SolveProblem problem={selected_problem} method={selected_method} />
{:else}
<GeneralError />
{/if}
Expand Down
6 changes: 5 additions & 1 deletion src/lib/components/main/SolveProblem.svelte
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
<script lang="ts">
import type { Problem } from "$lib/api";
import { selectedMethodName } from '$lib/store';

export let problem: Problem;
export let method: string;

// import NautilusNavigator from "$lib/components/methods/nautilus_navigator/NautilusNavigator.svelte";
// import NIMBUS from "$lib/components/methods/nimbus/NIMBUS.svelte";
import ReferencePointMethod from "$lib/components/methods/reference_point_method/ReferencePointMethod.svelte";
import IRVEAMethod from "$lib/components/methods/interactive_rvea/InteractiveRVEA.svelte";
import GeneralError from "../util/undecorated/GeneralError.svelte";

selectedMethodName.set('Interactive RVEA');
</script>

<!--
Expand All @@ -21,7 +25,7 @@
<!-- <NIMBUS {problem} /> -->
<!-- {:else if method === "reference_point_method"} -->
{#if method === "reference_point_method"}
<ReferencePointMethod {problem} />
<IRVEAMethod />
{:else}
<GeneralError />
{/if}
25 changes: 15 additions & 10 deletions src/lib/components/main/User.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script lang="ts">
import { login_status, username, logout, LoginStatus } from "$lib/api";
import { selectedMethodName } from "$lib/store";
import { goto } from "$app/navigation";

function handleLogout() {
Expand All @@ -9,16 +10,20 @@
}
</script>

<div class="flex gap-2">
{#if $login_status === LoginStatus.LoggedOut}
<span>Not logged in</span>
<span><a class="anchor" href="/login">Log in</a></span>
{:else}
{#if $login_status === LoginStatus.LoggedInAsUser}
<span>Logged in as <span class="font-bold">{$username}</span></span>
<div class="flex justify-between items-center w-full">
<span class="font-bold">{$selectedMethodName}</span>

<div class="flex gap-2">
{#if $login_status === LoginStatus.LoggedOut}
<span>Not logged in</span>
<span><a class="anchor" href="/login">Log in</a></span>
{:else}
<span>Logged in as a guest</span>
{#if $login_status === LoginStatus.LoggedInAsUser}
<span>Logged in as <span class="font-bold">{$username}</span></span>
{:else}
<span>Logged in as a guest</span>
{/if}
<button class="anchor" on:click={handleLogout}>Log out</button>
{/if}
<button class="anchor" on:click={handleLogout}>Log out</button>
{/if}
</div>
</div>
Loading