thegrumpys / pcyl-cli Goto Github PK
View Code? Open in Web Editor NEWPiston-Cylinder problem - Command Line Interface
License: MIT License
Piston-Cylinder problem - Command Line Interface
License: MIT License
These features need to be incorporated into the startup file.
It appears that we get mismatches between the JS and PLI output because ioopt is not implemented. So we need to implement checking ioopt for output. We do not need to SET IOOPT, because 5 is just fine.
Consider adding type: "string", "integer" and "float" to each constant, design parameter and state variable entry.
Add "oldvalue" property into design_parameters and state_variables as defined in design.js.
Write update code to store current values of design parameters and state variables into oldvalue for potential later use.
Invoke the update function in start.js.
Make corresponding changes in list.js so that old values appear in "BEFORE SEARCH" column.
I am trying to have us use a standard pattern for command decode whereby we shift split_line into variables, then check the variables using a regular expression before doing a parseFloat. This also removes the use of 'isNaN'.
Also change command in list.js to be an array
See last part of session output.
**********************************************
*** Welcome to PCyl Version 1.2
**********************************************
PCyl: fix radius 0.444
fix radius 0.444
RADIUS IS FIXED AT 0.4440 INCH
PCyl: search
search
SEARCH: OBJ = 0.476569
RETURN ON: OBJ = 0.002707
THE RESULT IS NOT FEASIBLE.
YOU NEED TO DO A LITTLE MORE WORK ON THIS DESIGN.
REFER TO THE DOCUMENTATION SECTION ON "FEASIBILITY" FOR SUGGESTIONS.
CONSTRAINT VIOLATIONS
VALUE LEVEL DIFFERENCE PERCENT
PRESSURE MAX 1552.8056 1500.0000 52.8056 3.5204 VIOLATED
FORCE MIN 961.6851 1000.0000 38.3149 3.8315 VIOLATED
VALUE OF THE OBJECTIVE FUNCTION AT THIS POINT IS: 0.002707
PCyl: list both
list both
INDEPENDENT VARIABLES CONSTRAINT LEVELS
STATUS MIN MAX
PRESSURE = 1552.8056 LB/SQ-IN 1500.0000
RADIUS = 0.4440 INCH FIXED 0.4440 0.4440
THICKNESS = -NaN INCH 0.0000 0.0500
DEPENDENT VARIABLES CONSTRAINT LEVELS
STATUS MIN MAX
FORCE = 961.6851 LBS. 1000.0000
STRESS = -NaN PSI 3000.0000
PCyl:
Calculate the value of Pi and return. The Spring specific version of this function will be far more complex … including user interaction.
List levels does not display full set of constraint levels.
List dependent displays a value for area where reading the PL/I code and execution of the JS code suggests that it shouldn't.
Also modify despak to expand parameter vector.
… and modify app.js to invoke start function after intro and before first command prompt.
Deferred list INTERNAL sub-command
File name should be passed in argument list.
Delay to 0.2
In order to better communicate that the program can be thought of as an "editor" for design files, it might be desirable to rename the START command to "Edit" or "Open".
Provide comparable substring abbreviation (startsWith()) feature.
The response to an empty command line seems to produce an extra prompt:
PCyl>
PCyl:
PCyl>
Perhaps this is part of a feature that echoes command input.
The state variable "area" is missing from some of the responses. For example:
list dep
DEPENDENT VARIABLES CONSTRAINT LEVELS
STATUS MIN MAX
force = 251.3274 LBS. 1000.0000
stress = 2500.0000 PSI 3000.0000
A list command followed by multiple (DPSV) names separated by a single space produces expected results. A list command followed by the same set of names separated by multiple blanks produces unexpected results.
For this case, the term in parens should be "outputs":
PCyl>list state
PCyl: list state
DEPENDENT VARIABLES (inputs)
force = 251.3274 LBS. 0.0000
area = 0.5027 SQ.-IN. 0.0000
stress = 2500.0000 PSI 0.0000
PCyl>
"list levels" does not produce a listing of constraint levels.
The first design parameter in the listing produced by "list design" has an extra blank space in the "BEFORE SEARCH" column.
PCyl>list design
PCyl: list design
INDEPENDENT VARIABLES (inputs) BEFORE SEARCH
pressure = 500.0000 LBS/SQ-IN 0.0000
radius = 0.4000 INCH 0.0000
thickness = 0.0400 INCH 0.0000
PCyl>
Got coverage working - woohoo!
Specifically the non-problem dependent, system initialization code.
Defer: INTERNAL sub-command; Defer: Pause procedure; Defer?: output to print file (checkpt)
I think we need to switch to readline-sync package to be able to handle these prompts.
That is: 'npm init'
Add #!/usr/bin/env node, and make it have execute permission. Also add "test": "./app.js < test/in.txt > test/out.txt" to package.json scripts to execute it. Add out.txt file to .gitignore.
The following listing illustrates the issue. Notes ...
The objective function value of the starting point has been validated by PL/I PCyl. This suggests that despak is working correctly for this case of fixed/free, etc.
It is expected that using the change command to reduce the minimum constraint on FORCE to zero results in an objective function of zero. However, after using the change command to restore the original constraint, the objective function value remains at zero. This aspect of the behavior is unexpected.
**********************************************
*** Welcome to PCyl Version 1.2
**********************************************
START:
The START command is not yet fully implemented.
PCyl: list both
list both
INDEPENDENT VARIABLES CONSTRAINT LEVELS
STATUS MIN MAX
PRESSURE = 500.0000 LB/SQ-IN 1500.0000
RADIUS = 0.4000 INCH 0.0000 0.5000
THICKNESS = 0.0400 INCH 0.0000 0.0500
DEPENDENT VARIABLES CONSTRAINT LEVELS
STATUS MIN MAX
FORCE = 251.3274 LBS. 1000.0000
STRESS = 2500.0000 PSI 3000.0000
PCyl: list viol
list viol
CONSTRAINT VIOLATIONS
VALUE LEVEL DIFFERENCE PERCENT
FORCE MIN 251.3274 1000.0000 748.6726 74.8673 VIOLATED
VALUE OF THE OBJECTIVE FUNCTION AT THIS POINT IS: 0.560511
PCyl: change force min 0.0
change force min 0.0
FORCE MINIMUM CHANGED TO 0.0 LBS.
PCyl: list both
list both
INDEPENDENT VARIABLES CONSTRAINT LEVELS
STATUS MIN MAX
PRESSURE = 500.0000 LB/SQ-IN 1500.0000
RADIUS = 0.4000 INCH 0.0000 0.5000
THICKNESS = 0.0400 INCH 0.0000 0.0500
DEPENDENT VARIABLES CONSTRAINT LEVELS
STATUS MIN MAX
FORCE = 251.3274 LBS. 0.0000
STRESS = 2500.0000 PSI 3000.0000
PCyl: list viol
list viol
NO CONSTRAINTS ARE VIOLATED
VALUE OF THE OBJECTIVE FUNCTION AT THIS POINT IS: 0.000000
PCyl: change force min 1000.
change force min 1000.
FORCE MINIMUM CHANGED TO 1000. LBS.
PCyl: list both
list both
INDEPENDENT VARIABLES CONSTRAINT LEVELS
STATUS MIN MAX
PRESSURE = 500.0000 LB/SQ-IN 1500.0000
RADIUS = 0.4000 INCH 0.0000 0.5000
THICKNESS = 0.0400 INCH 0.0000 0.0500
DEPENDENT VARIABLES CONSTRAINT LEVELS
STATUS MIN MAX
FORCE = 251.3274 LBS. 1000.0000
STRESS = 2500.0000 PSI 3000.0000
PCyl: list viol
list viol
NO CONSTRAINTS ARE VIOLATED
VALUE OF THE OBJECTIVE FUNCTION AT THIS POINT IS: 0.000000
PCyl:
For example, change from
for (let dp of design_parameters) {
if (dp.lmin != FIXEDSTAT) {
nfree++;
pc.push(dp.value);
}
}
to
var pc = [];
for (let i = 0; i < design_parameter.length; i++) {
var dp = design_parameter[i];
if (dp.lmin != FIXEDSTAT) {
nfree++;
pc[i] = dp.value;
}
}
These files allows you to run the program feeding it a series of commands, capturing the actual output, and then comparing it to the expected output.
node app.js < test/in.txt > test/actual_out.txt
diff -y -W 256 test/expected_out.txt test/actual_out.txt
This allows a quick check after making changes to verify the system is still operating as expected.
I suggest doing this at each release, and possibly more often. At each release the updated output should be checked in to replace the current test/expected_out.txt to incorporate the updates and prepare for the following release.
It appears that the problem is only in the acknowledgement; not in the value that is set for constraint levels.
The may be a good time to confirm that parseFloat() is also applied to constants and any other appropriate places in the change.js module.
**********************************************
*** Welcome to PCyl Version 1.2
**********************************************
PCyl: change thick max 0.155
change thick max 0.155
THICKNESS MAXIMUM CHANGED TO 0.0000 INCH
PCyl: change stress max 7000.1
change stress max 7000.1
STRESS MAXIMUM CHANGED TO 0.0000 PSI
PCyl:
PCyl: list thick
list thick
THICKNESS = 0.0400 INCH 0.0000 0.1550
PCyl: list stress
list stress
STRESS = 2500.0000 PSI 7000.1000
PCyl:
Deferred read of startup file.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.