@@ -40,12 +40,13 @@ Model Main_Knapsack {
4040 Set s_items {
4141 Index: i_item;
4242 Parameter: ep_selectedItem;
43- Comment: " ElementRange(1, p_maxItems , prefix:\ "item-\ ", fill:1)" ;
43+ Definition: ElementRange(1, p_itemQuantity , prefix:"item-", fill:1);
4444 }
4545 StringParameter sp_itemDescription {
4646 IndexDomain: i_item;
47+ InitialData: "";
4748 }
48- Parameter p_maxItems {
49+ Parameter p_itemQuantity {
4950 Text: "No. of items";
5051 Range: integer;
5152 InitialData: 14;
@@ -59,33 +60,47 @@ Model Main_Knapsack {
5960 Parameter p_itemWeight {
6061 IndexDomain: (i_item);
6162 Unit: lb;
63+ InitialData: 0;
6264 }
6365 Parameter p_maxWeightKnapsack {
6466 Text: "Max. weight knapsack";
6567 Unit: lb;
6668 InitialData: 60;
6769 }
70+ Parameter p_maxItemKnapsack {
71+ Text: "Max. item knapsack";
72+ InitialData: 10;
73+ }
6874 Parameter p_itemRangeMin {
6975 IndexDomain: (i_item);
7076 Range: integer;
77+ InitialData: 0;
7178 }
7279 Parameter p_itemRangeMax {
7380 IndexDomain: (i_item);
7481 Range: integer;
82+ InitialData: 0;
83+ webui::AnnotationsIdentifier: sp_maxRangeAnnotation;
84+ webui::TooltipIdentifier: sp_maxRangeTooltip;
7585 }
7686 Parameter p_itemBound {
7787 IndexDomain: (i_item);
7888 Text: "No. of copies that is allowed";
7989 Range: integer;
90+ InitialData: 0;
8091 }
8192 }
8293 Procedure pr_randomizeData {
8394 Body: {
84- empty p_itemValue, p_itemWeight, p_itemBound;
95+ empty p_itemValue, p_itemWeight, p_itemBound, p_itemRangeMax;
96+
97+ p_itemValue(i_item) := uniform(0, 200)*1[$];
98+ p_itemWeight(i_item) := uniform(0[lb], p_maxWeightKnapsack/3);
99+ p_itemBound(i_item) := ceil(uniform(0, 10));
85100
86- p_itemValue(i_item) := uniform(0,200)*1[$];
87- p_itemWeight (i_item) := uniform(0[lb],p_maxWeightKnapsack/3) ;
88- p_itemBound (i_item) := ceil(uniform(0,10)) ;
101+ !not random
102+ p_itemRangeMax (i_item) := 1 ;
103+ sp_itemDescription (i_item) := i_item ;
89104 }
90105 }
91106 }
@@ -122,6 +137,9 @@ Model Main_Knapsack {
122137 Unit: lb;
123138 Definition: sum(i_item, v_inline_knapsackWeight(i_item)) <= p_maxWeightKnapsack;
124139 }
140+ Constraint c_limitKnapsackItem {
141+ Definition: sum(i_item, v_knapsackItems(i_item)) <= p_maxItemKnapsack;
142+ }
125143 MathematicalProgram mp_knapsackModel {
126144 Objective: v_knapsackTotalValue;
127145 Direction: maximize;
@@ -213,7 +231,7 @@ Model Main_Knapsack {
213231 { ( '1', '1', 'displayText' ) : "Welcome" , ( '1', '1', 'icon' ) : "aimms-happy" ,
214232 ( '1', '1', 'pageId' ) : "home" , ( '1', '1', 'tooltip' ) : "welcome" ,
215233 ( '1', '1', 'workflowPageState' ) : "active" , ( '1', '1', 'pageDataState' ) : "Incomplete" ,
216- ( '1', '1', 'redirectPageId' ) : "home " , ( '1', '2', 'displayText' ) : "Story" ,
234+ ( '1', '1', 'redirectPageId' ) : "" , ( '1', '2', 'displayText' ) : "Story" ,
217235 ( '1', '2', 'icon' ) : "aimms-lamp5" , ( '1', '2', 'pageId' ) : "problem_description",
218236 ( '1', '2', 'tooltip' ) : "Problem description", ( '1', '2', 'workflowPageState' ) : "active" ,
219237 ( '1', '2', 'pageDataState' ) : "Incomplete" , ( '1', '2', 'redirectPageId' ) : "home" ,
@@ -227,71 +245,68 @@ Model Main_Knapsack {
227245 }
228246 }
229247 }
230- Section CRUD {
231- StringParameter sp_addEditElement;
232- Section CRUD_Items {
233- Procedure pr_openAddItem {
234- Body: {
235- empty sp_addEditElement;
236-
237- webui::OpenDialogPage(
238- pageId : 'crud',
239- title : "Add Items",
240- actions : s_loc_actions,
241- onDone : 'pr_addItem');
242- }
243- Set s_loc_actions {
244- InitialData: {
245- {'Cancel', 'OK'}
246- }
247- }
248- }
249- Procedure pr_addItem {
250- Arguments: sp_arg_action;
251- Body: {
252- if sp_arg_action = 'OK' then
253- ep_selectedItem := StringToElement(s_items, sp_addEditElement, 1);
254- endif;
255- }
256- StringParameter sp_arg_action {
257- Property: Input;
258- }
259- }
260- Procedure pr_openEditItem {
261- Body: {
262- sp_addEditElement := ep_selectedItem;
263-
264- webui::OpenDialogPage(
265- pageId : 'crud',
266- title : "Edit Restaurant",
267- actions : s_loc_actions,
268- onDone : 'pr_editItem');
269- }
270- Set s_loc_actions {
271- InitialData: {
272- {'Cancel', 'OK'}
273- }
274- }
248+ Section Status_Bar {
249+ Procedure pr_changeVisibility {
250+ Body: {
251+ if bp_dense then
252+
253+ sp_statusBar('1', 'header') := "Visibility";
254+ sp_statusBar('1', 'icon') := "aimms-filter";
255+ sp_statusBar('1', 'color') := "#505767";
256+ sp_statusBar('1', 'text') := "Showing Sparse";
257+ sp_statusBar('1', 'tooltip') := "Click to change visibility";
258+ sp_statusBar('1', 'procedure') := "pr_changeVisibility";
259+ sp_statusBar('1', 'state') := "active";
260+
261+ bp_sparse := 1;
262+ bp_dense := 0;
263+
264+ elseif bp_sparse then
265+
266+ sp_statusBar('1', 'header') := "Visibility";
267+ sp_statusBar('1', 'icon') := "aimms-filter2";
268+ sp_statusBar('1', 'color') := "#505767";
269+ sp_statusBar('1', 'text') := "Showing Dense";
270+ sp_statusBar('1', 'tooltip') := "Click to change visibility";
271+ sp_statusBar('1', 'procedure') := "pr_changeVisibility";
272+ sp_statusBar('1', 'state') := "active";
273+
274+ bp_sparse := 0;
275+ bp_dense := 1;
276+ endif;
275277 }
276- Procedure pr_editItem {
277- Arguments: sp_arg_action;
278- Body: {
279- if sp_arg_action = 'OK' then
280- SetElementRename(s_items, ep_selectedItem, sp_addEditElement);
281- endif;
282- }
283- StringParameter sp_arg_action {
284- Property: Input;
285- }
278+ Comment: "Showing Dense/ Showing Sparse/ Showing Inactives";
279+ }
280+ Procedure pr_setInitialStatusBar {
281+ Body: {
282+ empty sp_statusBar;
283+
284+ sp_statusBar('1', 'header') := "Visibility";
285+ sp_statusBar('1', 'icon') := "aimms-filter";
286+ sp_statusBar('1', 'color') := "#505767";
287+ sp_statusBar('1', 'text') := "Showing Sparse";
288+ sp_statusBar('1', 'tooltip') := "Click to change visibility";
289+ sp_statusBar('1', 'procedure') := "pr_changeVisibility";
290+ sp_statusBar('1', 'state') := "active";
291+ bp_sparse := 1;
286292 }
287- Procedure pr_deleteItem {
288- Body: {
289- s_items -= ep_selectedItem;
290-
291- ep_selectedItem := first(i_item);
292- }
293+ }
294+ StringParameter sp_statusBar {
295+ IndexDomain: (webui::indexApplicationExtension,webui::indexStatusBarSpec);
296+ InitialData: {
297+ data
298+ { ( 1, header ) : "Visibility" , ( 1, icon ) : "aimms-filter" ,
299+ ( 1, color ) : "red" , ( 1, text ) : "Showing Inactive" ,
300+ ( 1, tooltip ) : "Click to change visibility", ( 1, procedure ) : "pr_changeVisibility" ,
301+ ( 1, state ) : "active" }
293302 }
294303 }
304+ Parameter bp_sparse {
305+ InitialData: 0;
306+ }
307+ Parameter bp_dense {
308+ InitialData: 0;
309+ }
295310 }
296311 Section Pages {
297312 Section Inputs_Page {
@@ -313,51 +328,22 @@ Model Main_Knapsack {
313328 ( 6, procedure ) : "pr_solveKnapsackModelBounded" , ( 6, state ) : "active" }
314329 }
315330 }
316- StringParameter sp_itemItemActions {
317- IndexDomain: (webui::indexWidgetItemActionSpec,webui::indexPageExtension,webui::indexWidgetActionSpec);
318- Definition: {
319- data
320- { ( p_itemBound , 1, displaytext ) : "Add" , ( p_itemBound , 1, icon ) : "aimms-plus3" ,
321- ( p_itemBound , 1, procedure ) : "pr_openAddItem" , ( p_itemBound , 1, state ) : "active" ,
322- ( p_itemBound , 2, displaytext ) : "Edit" , ( p_itemBound , 2, icon ) : "aimms-pencil2" ,
323- ( p_itemBound , 2, procedure ) : "pr_openEditItem", ( p_itemBound , 2, state ) : "active" ,
324- ( p_itemBound , 3, displaytext ) : "Delete" , ( p_itemBound , 3, icon ) : "aimms-eraser2" ,
325- ( p_itemBound , 3, procedure ) : "pr_deleteItem" , ( p_itemBound , 3, state ) : "active" ,
326- ( p_itemRangeMax , 1, displaytext ) : "Add" , ( p_itemRangeMax , 1, icon ) : "aimms-plus3" ,
327- ( p_itemRangeMax , 1, procedure ) : "pr_openAddItem" , ( p_itemRangeMax , 1, state ) : "active" ,
328- ( p_itemRangeMax , 2, displaytext ) : "Edit" , ( p_itemRangeMax , 2, icon ) : "aimms-pencil2" ,
329- ( p_itemRangeMax , 2, procedure ) : "pr_openEditItem", ( p_itemRangeMax , 2, state ) : "active" ,
330- ( p_itemRangeMax , 3, displaytext ) : "Delete" , ( p_itemRangeMax , 3, icon ) : "aimms-eraser2" ,
331- ( p_itemRangeMax , 3, procedure ) : "pr_deleteItem" , ( p_itemRangeMax , 3, state ) : "active" ,
332- ( p_itemRangeMin , 1, displaytext ) : "Add" , ( p_itemRangeMin , 1, icon ) : "aimms-plus3" ,
333- ( p_itemRangeMin , 1, procedure ) : "pr_openAddItem" , ( p_itemRangeMin , 1, state ) : "active" ,
334- ( p_itemRangeMin , 2, displaytext ) : "Edit" , ( p_itemRangeMin , 2, icon ) : "aimms-pencil2" ,
335- ( p_itemRangeMin , 2, procedure ) : "pr_openEditItem", ( p_itemRangeMin , 2, state ) : "active" ,
336- ( p_itemRangeMin , 3, displaytext ) : "Delete" , ( p_itemRangeMin , 3, icon ) : "aimms-eraser2" ,
337- ( p_itemRangeMin , 3, procedure ) : "pr_deleteItem" , ( p_itemRangeMin , 3, state ) : "active" ,
338- ( p_itemValue , 1, displaytext ) : "Add" , ( p_itemValue , 1, icon ) : "aimms-plus3" ,
339- ( p_itemValue , 1, procedure ) : "pr_openAddItem" , ( p_itemValue , 1, state ) : "active" ,
340- ( p_itemValue , 2, displaytext ) : "Edit" , ( p_itemValue , 2, icon ) : "aimms-pencil2" ,
341- ( p_itemValue , 2, procedure ) : "pr_openEditItem", ( p_itemValue , 2, state ) : "active" ,
342- ( p_itemValue , 3, displaytext ) : "Delete" , ( p_itemValue , 3, icon ) : "aimms-eraser2" ,
343- ( p_itemValue , 3, procedure ) : "pr_deleteItem" , ( p_itemValue , 3, state ) : "active" ,
344- ( p_itemWeight , 1, displaytext ) : "Add" , ( p_itemWeight , 1, icon ) : "aimms-plus3" ,
345- ( p_itemWeight , 1, procedure ) : "pr_openAddItem" , ( p_itemWeight , 1, state ) : "active" ,
346- ( p_itemWeight , 2, displaytext ) : "Edit" , ( p_itemWeight , 2, icon ) : "aimms-pencil2" ,
347- ( p_itemWeight , 2, procedure ) : "pr_openEditItem", ( p_itemWeight , 2, state ) : "active" ,
348- ( p_itemWeight , 3, displaytext ) : "Delete" , ( p_itemWeight , 3, icon ) : "aimms-eraser2" ,
349- ( p_itemWeight , 3, procedure ) : "pr_deleteItem" , ( p_itemWeight , 3, state ) : "active" ,
350- ( sp_itemDescription, 1, displaytext ) : "Add" , ( sp_itemDescription, 1, icon ) : "aimms-plus3" ,
351- ( sp_itemDescription, 1, procedure ) : "pr_openAddItem" , ( sp_itemDescription, 1, state ) : "active" ,
352- ( sp_itemDescription, 2, displaytext ) : "Edit" , ( sp_itemDescription, 2, icon ) : "aimms-pencil2" ,
353- ( sp_itemDescription, 2, procedure ) : "pr_openEditItem", ( sp_itemDescription, 2, state ) : "active" ,
354- ( sp_itemDescription, 3, displaytext ) : "Delete" , ( sp_itemDescription, 3, icon ) : "aimms-eraser2" ,
355- ( sp_itemDescription, 3, procedure ) : "pr_deleteItem" , ( sp_itemDescription, 3, state ) : "active" }
356- }
331+ StringParameter sp_maxRangeTooltip {
332+ Definition: "This idenfifier may change after the run.";
333+ }
334+ StringParameter sp_maxRangeAnnotation {
335+ Definition: "different";
357336 }
358337 }
359338 Section Results_Page {
360339 DeclarationSection Result_Side_Panel {
340+ Set s_def_filteredItems {
341+ SubsetOf: s_items;
342+ Index: i_fitem;
343+ Definition: {
344+ {i_item | p_itemFilter(i_item)}
345+ }
346+ }
361347 StringParameter sp_resultsSidePanel {
362348 IndexDomain: (webui::indexPageExtension,webui::indexSidePanelSpec);
363349 Definition: {
@@ -391,6 +377,17 @@ Model Main_Knapsack {
391377 round(v_inline_knapsackValue(i_item), 2))
392378 }
393379 }
380+ Parameter p_dom_knapsackResult {
381+ IndexDomain: i_item;
382+ Definition: {
383+ 1 $ (!used by status bar visualization
384+ (v_knapsackItems(i_item)
385+ and v_inline_knapsackValue(i_item)
386+ and bp_dense)
387+ or
388+ bp_sparse)
389+ }
390+ }
394391 }
395392 }
396393 }
@@ -468,7 +465,7 @@ Model Main_Knapsack {
468465 block ! ReadSingleValue Import
469466 axll::SelectSheet("Knapsack");
470467
471- axll::ReadSingleValue(p_maxItems , "B1");
468+ axll::ReadSingleValue(p_maxItemKnapsack , "B1");
472469 axll::ReadSingleValue(p_maxWeightKnapsack, "B2");
473470
474471 endblock;
@@ -523,7 +520,7 @@ Model Main_Knapsack {
523520 axll::CreateSheet("Knapsack", "Item");
524521
525522 axll::WriteSingleValue(sp_loc_maxItemsTitle, "A1");
526- axll::WriteSingleValue(p_maxItems , "B1");
523+ axll::WriteSingleValue(p_maxItemKnapsack , "B1");
527524
528525 axll::WriteSingleValue(sp_loc_maxWeightKnapsackTitle, "A2");
529526 axll::WriteSingleValue(p_maxWeightKnapsack, "B2");
@@ -588,6 +585,9 @@ Model Main_Knapsack {
588585 }
589586 }
590587 Procedure MainInitialization {
588+ Body: {
589+ pr_setInitialStatusBar;
590+ }
591591 Comment: "Add initialization statements here that do NOT require any library being initialized already.";
592592 }
593593 Procedure PostMainInitialization {
0 commit comments