2024年2月7日水曜日

Python Code Generator

 スケジュールナースを使う場合、print出力は、求回右画面に出力されます。これをコピペすればよいのですが、以前バージョンの場合、全体のコピーになっていました。


最新バージョンではこれを改善し、選択した部分のコピーにしました。

これにより、生成コードをコピペ出来るようになりました。


2024年2月6日火曜日

夜勤は4人だが、1年生が働く夜勤は5人体制にしたい,長日勤は5人体制(1年生含んでOK)にしたい。

 変則2交代の原則は、長入明で、全て同じ人がアサインされることです。夜勤は、4人、長日勤は、5人だと、この原則を逸脱するような気がします。しかし、これも共通化する部分を作ることによって、この原則を貫きます。具体的には、夜勤4人、長日勤4人としてこれをコアとする制約を書きます。その上で、

1)1年生は、Max1人夜勤

2)長日勤単独は、1年生を含んで1人確保

とすれば、上記要求を満たすことになります。

このように、共通部は何か?をまず考え、それ以外の部分を次に考える、ということをすると良いと思います。

2024年2月5日月曜日

長日単独は、月一回以下としたい

 単純に、1回以下とせず、まず、予定ブランク時にこの制約は、常に満たせるか?を考えます。これは、講義ノートで、述べられている通り、「予定ブランク時は、UB=0を目指す」の原則によります。

https://nurse-scheduling-software.com/japanese/publications/schedule_nurse_lecture_note.pdf

例えば、夜勤要員28人に対して、1回以下で済むには、月の日数は、28日以下でなければなりません。大半の月は、必ずエラーが生じることになり、上記原則に反します。よって、夜勤要員28人の場合の制約は、

1回以上、2回以下とする

ことが正解になります。スタッフ間の負荷偏差が気になる場合は、月毎に累計し、スタッフプロパティシートで加減すればよいでしょう。

2024年2月4日日曜日

夜勤4人の内訳は、リーダーから2名、またはリーダー1名、準リーダー1名を含みたい。

A)リーダーから2名

B)リーダー1名、準リーダー1名

条件Aまたは、条件Bのどちらかの条件を満たしたい、ということです。

こういう場合の考え方は、「共通部は何か?」を考えることで、A)またはB)を満たします。

■リーダについて共通部を見ると、リーダは、1名以上

■人員2名について共通部を見ると、リーダまたは準リーダ集合は、2名以上

ということが言えます。それを素直に制約すれば、自然にA)またはB)を満たす結果となります。


2024年2月3日土曜日

2024年2月1日木曜日

Folder Restore Operation


 

When utilizing the folder dialog in Python with ctypes, it appears that the solver fails to provide a solution. This is likely because Python is executed at the front end of the solver startup and alters the default folder. Unfortunately, there is no known method to fix this issue other than having the user manually change the folder back to its default state.


import sc3
import datetime
import ctypes
import os
import csv
import win32gui, win32con

def get_open_file_name(title):
    filter='csv\0*.csv\0'
    customfilter='Other file types\0*.*\0'
    fname, customfilter, flags=win32gui.GetOpenFileNameW(
    InitialDir=project_file_path, 
    Flags=win32con.OFN_ALLOWMULTISELECT|win32con.OFN_EXPLORER,
    File='', DefExt='csv',
    Title=title,#
    Filter=filter,
    CustomFilter=customfilter,
    FilterIndex=0)
    return str(fname)

def get_shift_info():
    filename=get_open_file_name("Open CSV File")
    print(filename)
    list=[]
    with open(filename, encoding='utf8', newline='') as f:
        csvreader = csv.reader(f)
        for row in csvreader:
            list.append(row)
            print(row)
    

initial_path = os.getcwd() #Get initial folder path
#print(initial_path)
get_shift_info()#Your Operation
os.chdir(initial_path)#Restore initial folder path for solving engine.

pythonでファイル操作は、ディレクトリを戻す

 pythonでctypesフォルダダイアログを使うとソルバからの解がない状態になってしまうようです。pythonは、ソルバ起動の前段で実行されますが、自分自身が既定フォルダを変えてしまうようです。これは、ユーザ自身で元に戻す以外に対策方法はありません。

対策は、イニシャルフォルダを保存しておいて、抜けるときに元に戻すことです。


import sc3
import datetime
import ctypes
import os
import csv
import win32gui, win32con

def get_open_file_name(title):
    filter='csv\0*.csv\0'
    customfilter='Other file types\0*.*\0'
    fname, customfilter, flags=win32gui.GetOpenFileNameW(
    InitialDir=project_file_path, 
    Flags=win32con.OFN_ALLOWMULTISELECT|win32con.OFN_EXPLORER,
    File='', DefExt='csv',
    Title=title,#
    Filter=filter,
    CustomFilter=customfilter,
    FilterIndex=0)
    return str(fname)

def get_shift_info():
    filename=get_open_file_name("Open CSV File")
    print(filename)
    list=[]
    with open(filename, encoding='utf8', newline='') as f:
        csvreader = csv.reader(f)
        for row in csvreader:
            list.append(row)
            print(row)
    

initial_path = os.getcwd() #Get initial folder path
#print(initial_path)
get_shift_info()#Your Operation
os.chdir(initial_path)#Restore initial folder path for solving engine.